146 Commits

Author SHA1 Message Date
Esa Korhonen
2ca9337da1 Merge branch '2.2' into 2.3 2019-04-16 16:34:57 +03:00
Esa Korhonen
f8a22d0ac0 MXS-2344 Add setting for enabling SSL for replication
If the monitor setting "replication_master_ssl" is set to on, any CHANGE MASTER TO-command
will have MASTER_SSL=1. If set to off or unset, MASTER_SSL is left unchanged to match existing
behaviour.
2019-04-15 19:15:45 +03:00
Esa Korhonen
90da3a4d90 Remove MXS_MONITORED_SERVER mapping from MariaDBMon
The mapping was rarely used.
2018-11-21 10:30:11 +02:00
Esa Korhonen
1a046bd453 MXS-2168 Add 'assume_unique_hostnames'-setting to MariaDBMonitor
Adds the setting and takes it into use during replication graph creation
and the most important checks.
2018-11-21 10:30:11 +02:00
Esa Korhonen
ecc7442358 Detect manual commands faster
Previous, MariaDBMonitor would wait until the next monitor interval before detecting
a new manual command. The commands are now checked every 100 ms.
2018-11-08 19:12:00 +02:00
Esa Korhonen
184e187732 Different cluster operations use different parameter types
Only the parameters used by all operations are in the common class.
2018-11-07 12:55:59 +02:00
Esa Korhonen
a4ce4e4613 MariaDBServer no longer uses ClusterOperation
The functions in the server class now only use the general parameters object.
2018-11-07 12:55:59 +02:00
Esa Korhonen
0c203fa02d Don't redirect duplicate connections
The redirection method checks if a slave connection to the redirection
target already exists. If so, the connection is not modified. Also, failover
better detects duplicate connections during promotion.
2018-10-16 16:09:38 +03:00
Esa Korhonen
0cf8ea43f7 Redirect slaves of promotion target
This affects situations where the promoted server is a relay or multimaster
group member.
2018-10-16 16:09:38 +03:00
Esa Korhonen
f2067fcf7c Monitor cleanup
Removes unused code, compacts lines, moves code.
No functional changes.
2018-10-11 11:39:05 +03:00
Esa Korhonen
c10fab977d Cleanup slave connection copy & merge
The two cases are now separated. In switchover, the promotion and
demotion targets can swap connections between each other without worry.
In failover, the two connection lists must be merged semi-intelligently.

The slave connections of the two servers are now saved to the operation
descriptor object at the start of the operation. This allows slave status
updating during the operation.
2018-10-09 14:29:49 +03:00
Esa Korhonen
5cc4eb08ee Clean up mariadbmon.hh 2018-10-09 14:29:49 +03:00
Esa Korhonen
68d65682b5 Reorganize MariaDBServer code
The server-class keeps growing, so the additional classes are moved out of
the main class file.
2018-10-09 14:29:49 +03:00
Markus Mäkelä
75ea1b6ea1
Fix formatting of new(std::nothrow)
The code previously formatted everything as `new( std::nothrow)`.
2018-10-04 21:50:44 +03:00
Esa Korhonen
80c731f02a Fix verify_master_failure
The log message had changed, changed test to match. Also, the remaining
delay is now printed.
2018-10-04 13:38:10 +03:00
Esa Korhonen
86ae0c3e4d MXS-1845 Remove unneeded code & cleanup 2018-10-04 13:38:10 +03:00
Esa Korhonen
30eb21914f MXS-1845 Switchover cleanup
Several small changes:
Binlog is flushed at the end of old master demotion.
Only new master is required to catch up to old master.
Use the same replication check method as failover.
2018-10-04 11:45:33 +03:00
Esa Korhonen
d14b9bfe43 MXS-1845 Cluster stabilization rewrite
No longer writes events to the master, as this creates problems if the
promoted server was not the overall master. Instead, the slave status
output is inspected.
2018-10-02 11:09:16 +03:00
Esa Korhonen
1ca5d02abb MXS-1845 Add redirection code
Should work with multimaster replication.
2018-10-02 11:09:16 +03:00
Esa Korhonen
fe81b399b2 Use maxbase time and clock classes instead of std::chrono 2018-09-27 17:04:59 +03:00
Esa Korhonen
c58041d4fb Format MariaDBMonitor source
Some parts were manually edited for better results. No functional changes.
2018-09-26 12:49:14 +03:00
Esa Korhonen
bfb1c3f1b3 MXS-1944 Store switchover parameters in an object 2018-09-26 12:42:26 +03:00
Esa Korhonen
c20a17238b MXS-1944 Store failover parameters in an object
Several of the parameters are passed on from function to function. Having them all
in an object cleans things up and makes adding more data easier.
2018-09-26 12:26:35 +03:00
Esa Korhonen
02ac394e38 Cleanup slave status handling
Further reduce direct indexing slave status array to improve compatibility with
multimaster replication.
2018-09-19 13:37:24 +03:00
Esa Korhonen
56c84541df MXS-1712 Add reset replication to MariaDB Monitor
The 'reset_replication' module command deletes all slave connections and binlogs,
sets gtid to sequence 0 and restarts replication from the given master. Should be
only used if gtid:s are incompatible but the actual data is known to be in sync.
2018-09-14 17:15:05 +03:00
Markus Mäkelä
d11c78ad80
Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look
neater.
2018-09-10 13:22:49 +03:00
Niclas Antti
c447e5cf15 Uncrustify maxscale
See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
2018-09-09 22:26:19 +03:00
Esa Korhonen
7e6ce2d13f MXS-1937 Disable server events on master during switchover
The feature is behind a config setting.
2018-09-05 15:54:08 +03:00
Esa Korhonen
85d8a85cde Update master failure detection from slaves
The detection now works with multiple slave connections.
2018-08-29 17:07:52 +03:00
Esa Korhonen
a593d00c65 Simplify failed master detection
No longer depends on monitor events as the other operations do not
either. The active_event/new_event detection was removed, as these
only protect against a rare situation. A similar feature which
protects all the cluster modifications will be implemented later.
2018-08-29 17:04:05 +03:00
Esa Korhonen
9e566bc619 A master that is down with no running slaves can be replaced
This should be a more general way to detect situations where a DBA
or another MaxScale performs a failover.
2018-08-29 16:41:20 +03:00
Esa Korhonen
61bb172033 Cleanup failover/switchover
Replication settings warnings are printed once more. Changed some
parameter names to be more consistent within the monitor.
2018-08-23 10:28:47 +03:00
Esa Korhonen
f2dfd39f79 Clean up JSON diagnostics
Now prints all slave connections.
2018-08-22 12:23:28 +03:00
Esa Korhonen
3777da96bd Miscellaneous cleanup
Removes needless status assignments and unused code. Moves and modifies some comments.
2018-08-22 12:11:33 +03:00
Niclas Antti
24ab3c099c Move top of the file "#pragma once" to after the following comment (swap them). If the comment is a BPL update it to the latest one 2018-08-21 13:13:15 +03:00
Esa Korhonen
0d762b2019 MXS-2012 Remove old replication lag detection
The method was quite disruptive as it continuosly wrote to the database.
Also removed the MaxScale ID global, as it wasn't used for anything else.
2018-08-21 11:51:10 +03:00
Johan Wikman
f9ba8824d4 MXS-2004 Remove additional dependencies on maxscale/thread.h 2018-08-13 13:38:39 +03:00
Johan Wikman
e2902b6513 MXS-2002 Remove GenericFunction typedef
It does not save much in characters compared to std::function<void ()>
and it's a bit misleading as not just any callable object will do, but
only one that takes no argument and returns void.
2018-08-13 08:30:05 +03:00
Esa Korhonen
b9ec3f5130 Monitor json diagnostics printing cleanup
The 'events' and 'script' config values were defined for every monitor.
Removed the extra definitions and moved the variables to MXS_MONITOR.

MariaDBMonitor was printing config values a second time, they are
already printed by the caller.

Moved the events enum definition to the internal header since it's no longer
required by modules.

Added a default config setting "all" to 'events' to clarify that it enables
all events.
2018-08-10 11:19:09 +03:00
Esa Korhonen
3f2838ab36 Avoid repeated logging when retrying automatic failover or switchover
Prevents repeated logging of similar error messages.
2018-08-07 16:36:48 +03:00
Esa Korhonen
17c84a22c7 Refactor preparations to failover
The two operations are quite similar so the code should look
similar as well and use shared functions.
2018-08-07 16:33:56 +03:00
Esa Korhonen
c0bd5ca3a1 MXS-1905 Switchover if master is low on disk space
Required quite a bit of refactoring.
2018-08-06 13:24:05 +03:00
Markus Mäkelä
d22b02047f
Disable parameters on main worker
Disabling the parameter on the main worker prevents deadlocks if the
parameter is disabled at the same time a monitor diagnostic is executed.
2018-08-03 10:34:47 +03:00
Esa Korhonen
89dfc80f86 Better tracking for slave status bits
The monitor can now differentiate between slaves with a running
series of slave connections to the master from slaves with broken
links. Both still get the SERVER_SLAVE-flag if 'detect_stale_slave'
is on.

Also, relay servers must be running.
2018-07-31 14:53:29 +03:00
Esa Korhonen
cfa07c69ff Clean up switchover_check_current()
Now uses MariaDBServer.
2018-07-27 11:20:23 +03:00
Esa Korhonen
b421e56d1c Move execute_worker_task to MonitorInstance
The function is rather general and may of use to other monitor modules.
2018-07-24 15:07:18 +03:00
Esa Korhonen
382a017518 A master which is down for longer than failcount is considered an invalid master
If auto_failover is disabled and an alternative master exists, the
monitor will swap the master. This may break replication, but the
situation requires that the dba has set up a cluster with multiple
masters.
2018-07-20 15:47:23 +03:00
Esa Korhonen
c9570ff616 Check failover applicability to the cluster every turn
This should give an advance warning if a user tries to activate auto_failover
on a cluster which does not support it.
2018-07-20 15:33:47 +03:00
Esa Korhonen
862ae099b0 Construct diagnostics results in the monitor thread
MariaDBMonitor diagnostics printing is unsafe as some of the read
fields are arrays. To be on the safe side, the fields are now read
in the monitor worker thread.

Since diagnostics must work even for stopped monitors, a worker task
is used. In practice, it usually runs when the monitor is sleeping.
2018-07-20 10:18:58 +03:00
Esa Korhonen
590df89dbc Fix mm_mysqlmon test
Because of monitor changes, the test had wrong assumptions.
Renamed the test and updated it to use MaxCtrl for some queries.

Also, changed the type of the cycle container in the monitor to an
ordered map so that results are predictable.
2018-07-18 16:32:16 +03:00