5691 Commits

Author SHA1 Message Date
Johan Wikman
11a240cb15 MXS-1519 Use fw instance specific rules and users
The rules and users need to be distinct not only for each thread
but for each instance and thread.
2017-11-16 14:06:50 +02:00
Esa Korhonen
b63c6504a3 MXS-1513: Switchover script
First version of switchover script. Unsafe to run as it has no
timeouts for most queries. Also, removed code launching the
previous switchover_script.
2017-11-16 10:51:12 +02:00
Esa Korhonen
032b2f3846 MXS-1333: QLAFilter, add option to log execution time
Adds an option 'reply_time' to log_data. When enabled, query execution time
in milliseconds is logged. Execution time is measured as the time between
routeQuery and the first clientReply.
2017-11-15 16:56:39 +02:00
Markus Mäkelä
f41111b4bd MXS-1517: Retain stale master bit even on master failure
If a server goes down and it has the stale master bit enabled, all other
bits for the server are cleared. This allows failed masters that have been
replaced to be first detected and then reintroduced into the replication
topology.
2017-11-14 16:53:09 +02:00
Markus Mäkelä
b80f394cd0 Use explicit types
Use uint64_t instead of unsigned. This guarantees that the size of the
type is the same across all platforms.
2017-11-14 16:53:09 +02:00
Johan Wikman
9d686c4c41 MXS-1461 Create error message only when blocking
Only if the filter is in blocking mode, will a match cause an error
to be returned. Thus, no point in creating the error message unless
the filter is in blocking mode.
2017-11-14 13:03:07 +02:00
Johan Wikman
ea0f8978b2 MXS-1461 Update log messages of firewall rules
Whether or not a match causes the query to be blocked or to be allowed
depends on whether the filter is in white-listing or black-listing mode,
so better if the text is neutral.
2017-11-14 13:03:07 +02:00
Johan Wikman
3eba77f43e MXS-1461 Implement not_function
If the instance represents `not_function` then it is a match if the
used function is not found amongst the listed functions.
2017-11-14 13:03:07 +02:00
Johan Wikman
3993ece209 MXS-1461 Remove special handling for function + allow
No need for this when 'not_function' is available.
2017-11-14 13:03:07 +02:00
Johan Wikman
3215458b30 MXS-1461 Introduce 'not_function' rule
Using 'not_function' it is possible to match functions other than
a specific set of ones. That will make it significantly easier to
allow certain functions to be used with certain columns.

The special handling of no arguments to `function` in conjunction
with an allowing filter has been removed. The same effect can now
be achieved, without special handling, using `not_function`, no
arguments and a blocking filter.

Implementation will follow in a subsequent commit.
2017-11-14 13:03:07 +02:00
Johan Wikman
b2b72474d9 Initialize thread as well in test_trxtracking 2017-11-10 14:45:54 +02:00
Johan Wikman
6cc8bc36c1 Initialize in test_dcb
Make necessary initializations in test_dcb.
2017-11-10 14:45:54 +02:00
Johan Wikman
f2b9525032 Initialize thread as well in test_trxcompare 2017-11-10 14:45:54 +02:00
Johan Wikman
f152c118cb Name core tests consistently
Now, given a concept xyz,
* the main test file is called test_xyz.cc
* the executable is called test_xyz, and
* the ctest test is called text_xyz.
2017-11-10 14:45:54 +02:00
Johan Wikman
e68f16b099 Merge branch '2.2' into 2.2-mrm 2017-11-09 09:41:58 +02:00
Johan Wikman
3dbd201a86 MXS-1478 Provide daemon flag
With "--daemon" or "-n" MaxScale can now be told to run in daemon
mode, that is, it forks and the parent exits. This is the default
behaviour, but a flag to this effect is needed if the default
behaviour is changed.
2017-11-09 09:34:23 +02:00
Markus Mäkelä
cbb6739e00 Always open the SQLite database in binlogrouter
The SQLite database was mistakenly opened only when master GTID
registration was used.
2017-11-08 18:41:14 +02:00
Johan Wikman
0558a2195d MXS-1479 By default, refuse to run as root
MaxScale now refuses to run as root. However, it is possible to
start MaxScale as root, as long as a user to run MaxScale as is
provided as a command line argument.

It is possible to run as root by invoking MaxScale as root and
by specifying the MaxScale user to be root.
2017-11-08 16:03:05 +02:00
Esa Korhonen
3a13469691 MXS-1490 Fix bug with gtid_io_pos change check
The conditional was opposite to intention.
2017-11-08 10:46:51 +02:00
Esa Korhonen
a1a5947d61 MXS-1490: Parse Gtid_IO_Pos only when using Gtid
First check "Using_Gtid", as that should be always valid. If set to
"Slave_Pos", parse "Gtid_IO_Pos".
2017-11-08 10:46:51 +02:00
Johan Wikman
3a35d49ffe Merge branch '2.2' into 2.2-mrm 2017-11-08 10:44:35 +02:00
Johan Wikman
42d9064b04 Remoeve queuemanager.[h|cc] 2017-11-08 10:44:14 +02:00
Johan Wikman
b1b78a5be7 Remove references to QUEUE_CONFIG
Only used in conjunction with queued connections, which are not
enabled anyway. Once that comes on the table again, better to use
some standard data structures.
2017-11-08 10:44:14 +02:00
Johan Wikman
4cf01fa88f Remove 'failover_script' parameter
As the failover is now internal to MySQL Monitor, no failover
script parameter is needed.
2017-11-07 16:05:44 +02:00
Markus Mäkelä
dce073a684 MXS-1496: Don't assign slave status for masters
The slave and stale slave status bits should be cleared from a master if
it still has them.

Also used the correct functions to manipulate the bits instead of directly
setting them in the monitor.
2017-11-07 15:52:28 +02:00
Esa Korhonen
84e95cee96 MXS-1490: Query gtid_slave_pos only during failover
The value of the global gtid_slave_pos is only needed during
failover, so querying it every monitor loop is unnecessary. The
value is now only requested when deciding on a new master server
or when waiting for the selected promotion target to clear its
relay logs.

Also, when waiting for the logs to clear, gtid_io_pos must stay
constant or failover is cancelled. Io_pos advancing indicates that
the server is still receiving events from the old master.
2017-11-07 13:09:51 +02:00
Johan Wikman
f44020496a Merge branch '2.2' into 2.2-mrm 2017-11-07 12:05:33 +02:00
Johan Wikman
d7b8e95234 MXS-1489 Create mechanism for running concurrent tasks
This commit introduces maxscale::future, maxscale::packaged_task
and maxscale::thread that are modeled after C++11 std::future,
std::packaged_task and std::thread as described here:
http://en.cppreference.com/w/cpp/thread

The standard classes rely upon rvalue references (and move
constructors) introduced by C++11. As the C++ compilers we must use
are pre-C++11 that feature is obviously not present. The absence of
rvalue references is circumvented by implementing regular copy
constructors and assignment operators as if the arguments were rvalue
references.

In practice the above means that when one of these objects are copied,
the state is _moved_ rendering the copied object in default initialized
state. Some care is needed to ensure that unintended copying does not
occur.
2017-11-07 12:03:09 +02:00
Markus Mäkelä
4bca9aa023 Fix and improve binlogrouter GTID option processing
The transaction safety was checked even if master GTID registration was
disabled. This always caused a failure when the router was started without
the transaction safety parameter.

As transaction safety is required by the GTID registration, it is not very
helpful to refuse to start if an invalid set of options is detected. To
make usage of the master GTID registration easier, the transaction safety
is also automatically enabled.
2017-11-07 09:24:18 +02:00
Esa Korhonen
0bb54511b7 MXS-1490: Query binlog & gtid settings, read @@gtid_slave_pos
The Gtid_Slave_Pos returned by SHOW ALL SLAVES STATUS is not quite
reliable (MDEV-14182) so the variable version is used instead. Added
a convenience function for querying a single row of values.

Also,  gtid_strict_mode, log_bin and log_slave_updates are now
queried during failover. The first only causes a warning message
if disabled, the last two affect new master selection.
2017-11-06 12:23:35 +02:00
Markus Mäkelä
0131841787 Fix dbfwfilter and cachetester dependencies
The two depended on the PCRE2 and Connector-C libraries which means that
the libraries need to be built first. This information needs to be told to
CMake with the add_dependency call.
2017-11-05 19:24:56 +02:00
Johan Wikman
2115ad7911 Make lines <= 110 chars long 2017-11-02 09:29:24 +02:00
Esa Korhonen
e79a95cd96 MXS-1490: Parse Gtid-strings with multiple triplets
Gtid_Slave_Pos may contain multiple triplets even with single-source
replication if the domain has changed at some point. For failover, we
only need to know the current domain values, so the gtid-parsing now
accepts an optional domain parameter. The Gtid-class still only stores
one triplet of values.

When parsing the Show Slave Status result, Gtid_IO_Pos is parsed first.
The resulting domain is then read from Gtid_Slave_Pos.
2017-11-01 14:43:13 +02:00
Esa Korhonen
0f2c1ff7d6 MXS-1490: Wait for a slave to clear relay logs before promotion
When selecting the new master server, Gtid_IO_Pos is checked to
select the slave with the latest event in relay log. If there is a
tie, the slave that has processed most events wins.

It's possible that the winning slave has unprocessed events. In
this case, failover waits for the slave to complete processing the
log. The maximum wait is defined in monitor parameter
"failover_timeout", defaulting to 90 seconds. If time runs out
failover ends in failure.

The Gtid struct was separated to its own definition to handle gtid:s
easier.
2017-10-31 18:27:16 +02:00
Johan Wikman
daaf8f5c53 Merge branch '2.2' into 2.2-mrm 2017-10-31 16:24:10 +02:00
Johan Wikman
18bfc515e2 MXS-1474 Set correct default and fix typo 2017-10-31 15:09:54 +02:00
Johan Wikman
f52a0acbbe MXS-1474 Document and act in the same way
From the documentation:

   * `never`: When there is an active transaction, no data will be returned
     from the cache, but all requests will always be sent to the backend.
     The cache will be populated inside _explicitly_ read-only transactions.
     Inside transactions that are not explicitly read-only, the cache will
     be populated _until_ the first non-SELECT statement.
   * `read_only_transactions`: The cache will be used and populated inside
     _explicitly_ read-only transactions. Inside transactions that are not
     explicitly read-only, the cache will be populated, but not used
     _until_ the first non-SELECT statement.
   * `all_transactions`: The cache will be used and populated inside
     _explicitly_ read-only transactions. Inside transactions that are not
     explicitly read-only, the cache will be used and populated _until_ the
     first non-SELECT statement.
2017-10-31 10:58:03 +02:00
Johan Wikman
e45ee22ec3 MXS-1474 Refactor for forthcoming changes 2017-10-31 10:58:03 +02:00
Johan Wikman
93edc230f9 MXS-1474 Use enum instead of boolean
Clearer for the reader with an explicit value indicating the desired
action, instrad of a boolean whose meaning is implicit.
2017-10-31 10:58:03 +02:00
Johan Wikman
20bb825882 MXS-1474 Factor out functionality
More changes coming, so better to factor out the COM_QUERY handling.
2017-10-31 10:58:03 +02:00
Johan Wikman
cb5c22269e MXS-1474 Take 'cache_in_transactions' into account
When deciding whether the cache should be consulted or not,
the value of the configuration parameter 'cache_in_transaction'
is taken into account as well.
2017-10-31 10:58:03 +02:00
Johan Wikman
c15eaf2f36 MXS-1474 Accept 'cache_in_transactions' parameter
Only the handling of the configuration parameter.
2017-10-31 10:58:03 +02:00
Markus Mäkelä
3a78b716b8 Merge branch '2.2' into 2.2-mrm 2017-10-30 11:06:34 +02:00
Markus Mäkelä
a971aa25da Merge branch '2.1' into 2.2 2017-10-30 11:01:19 +02:00
Esa Korhonen
41cd0cd6d7 MXS-1490 Separate SlaveStatus information to its own class
The SlaveStatus info is now in a separate class, although it's
still embedded in the MYSQL_SERVER_INFO-class. Both classes now
use strings intead of char*:s.
2017-10-30 10:33:41 +02:00
Markus Mäkelä
63cbf56cb2 MXS-1500: Fix real_type values
The characters in the type weren't checked for correctness which caused
the processing to read more characters than was intended.
2017-10-30 10:25:03 +02:00
Markus Mäkelä
551bb81929 Loosen the atomicity requirement for the passive parameter
As the passive parameter is only used by the failover and the failover can
only be initiated by the monitor, there is no true need to synchronize the
reads and write of this parameter.

As all runtime changes are protected by the runtime lock, only partial
reads are of concern. For the supported platforms, this is not a practical
problem and it only confuses the reader when other variables are modified
without atomic operations.
2017-10-27 15:31:46 +03:00
Markus Mäkelä
600509be4a Fix master failure tracking
The master failure was assumed to be the only master related event for
each monitoring loop. If the master was switched by an external actor, the
monitor tracking would be out of sync.
2017-10-27 15:31:46 +03:00
Markus Mäkelä
c7c670930c MXS-1493: Check that master appears dead before verifying it
Before the verification of the master's failure is done, the master must
first appear to have failed.
2017-10-27 15:31:46 +03:00
Markus Mäkelä
0bc439641a Add helper function for reading values by field name
The helper function provides map-like access to row values. This is used
to retrieve the values for all MariaDB 10.0+ versions as there are
differences in the returned results between 10.1 and 10.2.
2017-10-27 15:31:46 +03:00