92 Commits

Author SHA1 Message Date
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
a3adcea524 MXS-1712 Cleanup reset-replication
Now logs messages explaining what has been done. Scheduled events are
disabled/enabled during the operation. Redirection of slaves is done at
the end similar to failover/switchover.
2018-09-21 10:54:36 +03:00
Markus Mäkelä
71ffef5708
Partially revert 4ba011266843857bbd3201e5b925a47e88e1808f
Add back leading operator enforcement.
2018-09-20 15:57:30 +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
Esa Korhonen
cb54880b99 MXS-1937 Cleanup event handling
Event handling is now enabled by default. If the monitor cannot query the EVENTS-
table (most likely because of missing credentials), print an error suggesting to
turn the feature off.

When disabling events on a rejoining standalone server (likely a former master),
disable binlog event recording for the session. This prevents the ALTER EVENT
queries from generating binlog events.

Also added documentation and combined similar parts in the code.
2018-09-14 16:54:24 +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
f3fbb297a4 MXS-1937 Enable server events on new master during switchover and failover
Combined some of the shared code in enable/disable_events(). Also disables
events on a joining standalone server.
2018-09-05 15:54:08 +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
7cd1cfdb80 Relay log waiting is part of failover_prepare
Since the servers are not modified before or during the wait, the waiting
can be done in the preparation method. This simplifies the actual failover
somewhat, and allows the monitor to keep running normally while waiting for
the log to clear.
2018-08-30 17:07:34 +03:00
Esa Korhonen
c39177bc8d Relay log clear supports multiple slave connections
Now waits for the relay log of the correct slave connection.
2018-08-29 17:07:52 +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
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
916b72a733 Clean up loops
Changed many of the iterator loops to range loops.
2018-08-22 12:22:45 +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
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Esa Korhonen
44a57dbefd Master can be a slave
This is possible if read_only is turned ON on the master and there is
no alternative master to swap to.
2018-08-21 11:51:10 +03:00
Johan Wikman
8f257a51fe MXS-2008 Remove unused headers from worker.hh
Add corresponding headers to files that depended on those headers.
2018-08-20 11:15:14 +03:00
Johan Wikman
f9ba8824d4 MXS-2004 Remove additional dependencies on maxscale/thread.h 2018-08-13 13:38:39 +03:00
Esa Korhonen
681c456bd7 Separate unknown server version from old versions
This allows better failover support detection.
2018-08-13 11:30:21 +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
Esa Korhonen
1e33ab69f2 Rename server_is_running() to server_is_usable()
The previous name was misleading. The new server_is_running() only
checks for the running bit so that a server is always either running
or down.
2018-07-31 14:53:56 +03:00
Esa Korhonen
cfa07c69ff Clean up switchover_check_current()
Now uses MariaDBServer.
2018-07-27 11:20:23 +03:00
Esa Korhonen
18bfca0533 Define inline functions for status variables
The functions are used in MariaDB Monitor.
2018-07-27 11:20:23 +03:00
Esa Korhonen
fbce38878b Turn server status macros to functions 2018-07-25 11:19:47 +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
Markus Mäkelä
bded99aea3
Assign slave status even if no master is available
The master validity check now checks if the master is down. This requires
that the slave status is assigned even if no master is available.

The failover precondition is also fulfilled as long as one valid promotion
candidate is found. Previously a slave that didn't use GTID replication
appeared to prevent failover.
2018-07-17 11:52:18 +03:00
Esa Korhonen
fd31c9cced MXS-1905 Set slaves with low disk space to maintenance
Also, servers in maintenance are updated just as other servers.
2018-07-02 14:24:57 +03:00
Esa Korhonen
9525d3507b Run manual commands without stopping the monitor
The command is saved in a function object which is read by the monitor
thread. This way, manual and automatic cluster modification commands are
ran in the same step of a monitor cycle.

This update required several modifications in related code.
2018-06-28 16:56:41 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Esa Korhonen
58207ec414 MXS-1775 Check disk space warning bit when selecting a new master for failover
This also applies to autoselect switchover. The disk space warning has the least
priority, as the other criteria could lead to replication failures. Also, print
the reason the new master was selected over the second best candidate.
2018-06-18 17:59:19 +03:00
Esa Korhonen
019d62bbb8 MXS-1886 Better auto-rejoin error description and tolerance
Contains changes from commit 09df01752812444c6e7c409a8957d292f7de63cf
adapted to the 2.3 branch.
2018-06-18 16:35:28 +03:00
Esa Korhonen
d3e9cc9a4f MXS-1886 Auto-failover error tolerance
Contains changes from commit 9e68d8ec3ddf1621f533067021c4b3042f695e80
adapted to the 2.3 branch.
2018-06-18 16:35:28 +03:00
Esa Korhonen
5324a1bdaa MXS-1845 Assign server roles
Assign server roles (master, slave, relay master, slave of external master)
for a graph with possibly multiple paths to a slave server.
2018-06-13 17:38:53 +03:00
Esa Korhonen
37841183b3 Cleanup server.h
Renamed, rearranged and clarified status bits. Removed unused macros.
2018-06-01 14:29:51 +03:00
Johan Wikman
a82c5911e5 MXS-1775 Rename m_monitor_base to m_monitor
To make it compatible with how the variable is named
in maxscale::MonitorInstance.
2018-06-01 13:48:15 +03:00
Johan Wikman
f862939dd7 MXS-1775 Make MariaDBMon non-dependent on stop() return value
To align it with the behavour or MonitorInstance::stop()
2018-06-01 13:48:15 +03:00
Esa Korhonen
3ec449339f Only write to SERVER->status at the end of a monitoring loop
This makes the code clearer and reduces race conditions, as the monitor
could be writing SERVER->status while a router is reading it. Also,
the time during which the SERVER struct is locked drops to a fraction.
2018-05-23 16:19:08 +03:00
Esa Korhonen
043232990c MXS-1859 Correct merge bug
Version comparison was wrong.
2018-05-21 15:58:12 +03:00
Esa Korhonen
709c076000 Merge branch '2.2' into develop 2018-05-18 16:31:49 +03:00
Esa Korhonen
df4454027a Clean up monitor initialization and destruction
Since monitors are now freed at MaxScale exit, the server data should be freed. Also,
gtid domain variables are now initialized with a common constant.
2018-05-14 11:32:02 +03:00
Johan Wikman
44fa2a4be2 MXS-1848 Change prototype of startMonitor
StartMonitor() now takes a MXS_MONITOR_INSTANCE and returns
true, if the monitor could be started and false otherwise.
So, the setup is such that in createInstance(), the instance
data is created and then using startMonitor() and stopMonitor()
the monitor is started/stopped. Finally in destroyInstance(),
the actual instance data is deleted.
2018-05-07 14:08:36 +03:00
Johan Wikman
60228f0f26 MXS-1848 Implement createInstance() and destroyInstance()
CreateInstance() (renamed from initMonitor()) and destroyInstance()
(renamed from finishMonitor()) have now tentatively been
implemented for all monitors.

Next step is to

1) change the prototype of startMonitor() to

       bool (*startMonitor)(MXS_SPECIFIC_MONITOR*,
                            const MXS_MONITOR_PARAMETER*);

   and assume that mon->handle will always contain the
   instance,
2) not delete any data in stopMonitor(),
3) add monitorCreateAll() that calls createInstance() for all
   monitors (and call that in main()), and
4) add monitorDestroyAll() that calls destroyInstance() for
   all monitors (and call that in main()).
2018-05-07 14:07:05 +03:00
Esa Korhonen
10b2b4ac37 MXS-1703 Use monitor-specific array instead of linked list
Also starting cleanup of server specific monitor code.
2018-05-07 13:51:27 +03:00
Niclas Antti
02b6cd7004 MXS-173 Initial version of throttle filter 2018-04-30 08:51:50 +03:00
Esa Korhonen
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
Esa Korhonen
de1e299f3f MXS-1745 Save all rows from SHOW ALL SLAVES STATUS
The master down verification through slaves won't work with this commit. It needs to be
redesigned to handle multiple slave connections or removed. Also, only the first row of
slave status data is used by the monitor, so multiple slave connections are still
incorrectly handled.
2018-04-27 10:48:45 +03:00