74 Commits

Author SHA1 Message Date
Esa Korhonen
17c9ac95bd MXS-1845 Add unit test for the cycle find algorithm (Tarjan SCC)
Only a few test cases for now.
2018-06-05 16:33:51 +03:00
Esa Korhonen
9a0445cd4e MXS-1845 Save cycle members
The saved data may be useful later on. Also includes some cleanup.
2018-06-05 16:25:04 +03:00
Esa Korhonen
4d7aff4ab9 MXS-1845 Find strongly connected components with multiple slave connections
Rewrote the algorithm for clarity.
2018-06-01 14:04:50 +03:00
Johan Wikman
32c7ae2f9f MXS-1775 Inherit MariaDBMonitor from mxs::MonitorInstance
Start/stop now provided by MonitorInstance. The thread main
function is now virtual and overriden by MariaDBMonitor. Some
additional refactoring is necessary in order to be able to allow
MonitorInstance to handle the main loop.
2018-06-01 13:48:15 +03:00
Johan Wikman
be3bdc7bc9 MXS-1775 Rename MariaDBMonitor::main_loop() to main()
To make it compatible with mxs::MonitorInstance.
2018-06-01 13:48:15 +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
Johan Wikman
62f3e89ae7 MXS-1775 Tilt MariaDbMon towards maxscale::MonitorInstance
- m_status -> m_state
- m_keep_running -> m_shutdown
- load_config_params() -> configure()
2018-06-01 13:48:15 +03:00
Johan Wikman
b439857a84 MXS-1775 Remove destroy()
Now the instance is deleted simply by deleting it.
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
4788c4947d Merge branch 'read_only' into develop
develop was updated before a merge was pushed, requiring a second merge.
2018-05-18 16:51:38 +03:00
Esa Korhonen
709c076000 Merge branch '2.2' into develop 2018-05-18 16:31:49 +03:00
Johan Wikman
d5871e48ae MXS-1775 Change assumption of Monitor::destroy() function
Used to be assumed to be a static member function, now assumed
to be a regular member function.
2018-05-18 16:00:05 +03:00
Esa Korhonen
45da5a08d9 MXS-1845 Cleanup monitor backend updating
Now detects errors and prints them.
2018-05-18 13:48:08 +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
Esa Korhonen
97328a61f0 Use MonitorApi in MariaDBMonitor 2018-05-14 11:11:08 +03:00
Esa Korhonen
b92284afc4 Move server querying to MariaDBServer
The query functions still require the base monitor struct because of
mon_ping_or_connect_to_db().
2018-05-14 11:11:08 +03:00
Esa Korhonen
0b459c0496 Always check monitor permissions when starting monitor
Servers could have been added while monitor was down so better be on the safe side.
2018-05-14 11:11:08 +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
5c1083c4aa MXS-1848 Parameters are not available at createInstance time
The monitor parameters are not available when the monitor instance
is created so at least for the time being they are removed from
the API.
2018-05-07 14:08:36 +03:00
Johan Wikman
81654fb0e7 MXS-1848 Rename monitor types and instance variable
The following type name changes

  MXS_MONITOR_OBJECT   -> MXS_MONITOR_API
  MXS_SPECIFIC_MONITOR -> MXS_MONITOR_INSTANCE

Further, the 'handle' instance variable of what used to be
called MXS_MONITOR_OBJECT has been renamed to 'api'.

An example, what used to look like

   mon->module->stopMonitor(mon->handle);

now looks like

  mon->api->stopMonitor(mon->instance);

which makes it more obvious what is going on.
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
Johan Wikman
d4008f7b28 MXS-1848 Introduce a specific monitor type
Instead of using void there's now a MXS_SPECIFIC_MONITOR struct
from which monitor specific types can be derived. This change
does not bring about other benefits than a bit of clarity but
this is the first step in clearing up the monitor API.
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
Esa Korhonen
289f4990d6 Merge branch '2.2' into develop 2018-04-23 11:48:38 +03:00
Esa Korhonen
02c57c98e4 MXS-1703 Move more methods to MariaDBServer
These methods only modify or update a single server.
2018-04-18 10:27:16 +03:00
Esa Korhonen
91e6874ac0 MXS-1703 Failover launch code cleanup
Removed one field from MXS_MONITOR, as it was only used by mariadbmon and is
unnecessary (the case it handled was impossible).
2018-04-18 10:27:16 +03:00
Esa Korhonen
c43f64c87e MXS-1703 Cleanup more methods
Most monitor functions now work with the monitor's own server class.
2018-04-16 13:48:56 +03:00
Esa Korhonen
3c8d3feff9 MXS-1703 Run astyle, rewrite comments & reorder fields
No functional changes.
2018-04-13 13:33:13 +03:00
Esa Korhonen
f7cc2aed5a MXS-1703 Remove MariaDBServer value array type
Having two types of arrays was more trouble than worth. Clearer to just
use the array of pointers. Renamed ServerRefArray to ServerArray.
2018-04-13 10:08:57 +03:00
Esa Korhonen
9fe57bfb9b MXS-1703 Change type of m_master to MariaDBServer 2018-04-13 10:08:57 +03:00
Esa Korhonen
b6e421e13b MXS-1703 Use a common header for all mariadbmon files
The mariadb_common.hh file is now a header with only common definitions
such as module name. The QueryResult-class was moved to MariaDBServer.
2018-04-12 13:06:36 +03:00
Esa Korhonen
ca9682f042 MXS-1703 Reorganize cluster manipulation methods
Just moving code around.
2018-04-12 13:06:36 +03:00
Esa Korhonen
4ba79e8d49 MXS-1703 Cleanup cluster manipulation code
Server arrays use the MariaDBServer type.
2018-04-12 13:06:22 +03:00
Esa Korhonen
b34e0000b4 MXS-1768 Allow autoselect for new master in switchover
Autoselection is allowed for current master only, or both current and new master.
Autoselection is not allowed for just the new master.

Also, do_switchover() writes to its parameters when autoselecting for
better error messages.
2018-04-12 10:04:36 +03:00
Esa Korhonen
d8a16dfe21 MXS-1703 Cleanup manual cluster modification command handling
Switchover checks are performed after monitor is stopped to be analogous to
other operations.
2018-04-12 10:04:36 +03:00
Esa Korhonen
7f06c02f89 MXS-1703 Reduce use of MXS_MONITORED_SERVER in main loop
The base class should only be used with general monitor functions
and macros.
2018-04-09 14:57:16 +03:00
Esa Korhonen
54121ed98b MXS-1703 Cleanup monitor interval waiting
The monitor now measures how long it should wait to get one interval.
2018-04-09 10:56:31 +03:00
Esa Korhonen
8b642dbb5e MXS-1703 Rename typedefs in preparation for more changes
Also moved some code around.
2018-04-09 10:55:55 +03:00
Esa Korhonen
71004a0ebc MXS-1703 Rearrange functions
Some functions were moved to class methods, others were moved to a different file.
All MariaDBMonitor fields are now private. Cleaned header a bit.
2018-04-09 10:54:34 +03:00
Esa Korhonen
147355bbdb MXS-1744 Use gtid querying instead of MASTER_GTID_WAIT when waiting for catchup
MASTER_GTID_WAIT uses gtid_slave_pos when comparing to the target gtid. This creates
problems with multi-domain gtids. It's simpler to just query the server for its
gtids repeatedly. Also, the method is now in MariaDBServer.
2018-04-09 10:51:16 +03:00
Esa Korhonen
174db469f3 MXS-1744 Rename and clean up gtid code, move to separate file
Renamed the two gtid-classes to better match MariaDB documentation. One
domain-server-sequence-combination is now a "Gtid", as these identify
a transaction. A "GtidList" contains a list of Gtid:s for handling multi-domain
server variables composed of multiple comma separated Gtid:s.

Removed unused methods and renamed some existing ones. Moved the Gtid-code
to its own file.
2018-04-06 10:23:02 +03:00
Esa Korhonen
e43678bed9 MXS-1744 Take new Gtid-class into use
Also cleaned up mariadbserver a bit.
2018-04-06 10:16:29 +03:00
Esa Korhonen
aaa8c92886 MXS-1744 Implement a Gtid-class which can store multi-domain gtid:s
The operations between Gtid:s are now more complicated so the class implements
them instead of the monitor. The Old Gtid-container has been renamed
GtidTriplet, and only stores the values for one triplet.
2018-04-04 15:53:42 +03:00
Esa Korhonen
923de851f9 MXS-1703 Move more functions to MariaDBServer
Also, the QueryResult integer reading method now only reads non-negative integers
since the server rarely returns negative values. This frees negative values for
indicating parsing error(s).

Gtid-class was moved back to utility.hh/.cc because the QueryResult-class requires it.
2018-03-28 13:47:07 +03:00
Esa Korhonen
1d5128fc5b MXS-1703 Move do_show_slave_status() to MariaDBServer
Also took into use the QueryResult helper class.
2018-03-27 12:43:36 +03:00
Esa Korhonen
a350de1275 MXS-1703 Move MariaDBServer to its own file
generate_master_gtid_wait_cmd() is now a method of the Gtid-class.
2018-03-23 13:13:01 +02:00
Esa Korhonen
e5dddf5f74 MXS-1703 Clean up monitor main loop function
Several blocks have been moved to their own functions to shorten
the main function.
2018-03-22 15:45:25 +02:00
Esa Korhonen
0b5601a6c8 MXS-1703 Rename MySqlServerInfo, prepare to use it as the primary class
Renamed to MariaDBServer. The objects have a pointer to the underlying
MXS_MONITORED_SERVER. The purpose is to have the monitor mainly use
MariaDBServer instead of the current mix of MXS_MONITORED_SERVER* and
MySqlServerInfo and to simplify the mapping between the two. Also,
many methods can be moved to the MariaDBServer class later on.

Some functions have been converted from MXS_MONITORED_SERVER* to
MariaDBServer.
2018-03-21 15:35:36 +02:00
Esa Korhonen
09a22b26c8 MXS-1703 Fix uninitialized pointer in manual switchover
If the current master was given by user, maxscale would crash.
2018-03-20 14:30:15 +02:00