146 Commits

Author SHA1 Message Date
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
654b5f1958 MXS-1865 Wrong permissions on backends no longer cause monitor start to fail
The logic was weird, as the permission checking function assumes a disconnected
server as fine. The checking is now done when starting the main loop and lacking
grants print errors but does not stop the monitor.
2018-05-16 13:55:45 +03:00
Esa Korhonen
b71710e066 MXS-1865 Combine server version and type
Binlog server is now handled better.
2018-05-16 13:55:45 +03:00
Esa Korhonen
b29bae6e84 MXS-1865 Update server version only when (re)connecting
Updating it every iteration is needless.
2018-05-16 13:55:45 +03:00
Esa Korhonen
c6b8277281 Cleanup server status querying
No functional changes except that status changes are no longer logged when
querying. It was bugged to begin with.
2018-05-14 11:32:02 +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
38647a0c69 Increase monitor sleep accuracy
Now the last sleep of a monitor loop is of correct duration.
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
Esa Korhonen
370b3be576 MXS-1703 Support "Preparing" in Slave_IO_Running
Is interpreted as "Connecting".
2018-05-09 12:49:23 +03:00
Esa Korhonen
0c5af4b13f Merge branch '2.2' into develop 2018-05-08 14:10:52 +03:00
Esa Korhonen
39789c19d3 MXS-1856 Do not set read_only OFF if join_cluster() fails
This could in some cases leave read_only OFF even if the target slave
begins replication.
2018-05-08 13:56:57 +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
510eb7ec7c MXS-1848 Change monitorCamelCase to monitor_snake_case 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
02cd7b9275 MXS-1848 Add initMonitor() and finishMonitor() functions.
Not called and implementations are dummies.
2018-05-07 14:07:05 +03:00
Johan Wikman
ec8b9c773a MXS-1848 Use MXS_SPECIFIC_MONITOR type in monitor APIs
Now, all monitor functions but startMonitor takes a
MXS_SPECIFIC_MONITOR instead of MXS_MONITOR. That is, startMonitor
is now like a static factory member returning a new specific
monitor instance and the other functions are like member functions
of that instance.
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
b44f2cfa36 Remove SERVER->slaves field
The field was only used by MariaDB-Monitor. A later commit will add equivalent
information to the monitor diagnostics function.
2018-05-07 13:51:06 +03:00
Markus Mäkelä
3030799ae1
Fix GTID updating for slaves
The updating of GTIDs was only considered successful if both the current
GTID position and binlog GTID positions were non-empty. If a slave has no
binlogged events, the GTID update would always fail.

This change in behavior caused the mysqlmon_failover_auto and
mysqlmon_failver_manual tests to break. The test disabled the binary log
on one of the servers which caused it to be left out from the rejoining
process.
2018-05-03 09:46:45 +03:00
Niclas Antti
02b6cd7004 MXS-173 Initial version of throttle filter 2018-04-30 08:51:50 +03:00
Markus Mäkelä
39ca403ffa
Deprecate mysql51_replication
Added back mysql51_replication and deprecated it. This allows old
configurations to be gracefully upgraded to 2.3 versions.
2018-04-27 12:34:37 +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
ba4700a983 MXS-1745 Remove unused fields
The binlog file and position are no longer used. Gtid_IO_Pos can fulfill
the same purpose if needed.
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
Esa Korhonen
7c933df56f MXS-1703 Remove support for MariaDB/MySQL versions less than 5.5
5.1 to 5.3 are officially not supported anymore, so support can be removed from
the monitor. This allows removing the config parameter "mysql51_replication".
2018-04-26 10:47:57 +03:00
Esa Korhonen
8e3bec5d09 MXS-1703 Rename fields in SlaveStatus
Althought the fields are still public, having the 'm_' is clearer.
2018-04-26 10:47:57 +03:00
Esa Korhonen
a28aac8de0 MXS-1703 Cleanup do_show_slave_status()
Slave_IO_Running is now properly parsed. Renamed class to SlaveStatus.
2018-04-26 10:47:57 +03:00
Esa Korhonen
caa964fa57 Merge branch '2.2' into develop 2018-04-24 13:57:50 +03:00
Esa Korhonen
2a38902aa6 MXS-1639 Discard results when executing sql text files
This removes the limitation of not returning resultsets.
2018-04-24 13:21:44 +03:00
Esa Korhonen
fa7cd9450a MXS-1639 Do not run demote_sql_file if the server already has a slave connection
In this case, the server was already a slave and is not being demoted. Also, the file may
contain queries which cannot be ran while a slave connection is running.
2018-04-24 13:21:44 +03:00
Esa Korhonen
289f4990d6 Merge branch '2.2' into develop 2018-04-23 11:48:38 +03:00
Esa Korhonen
739edcbe22 MXS-1639 Run user-given sql commands during promotion, demotion and rejoin
The sql queries are given in two text files, defined by options promotion_sql_file
and demotion_sql_file. The files must exist when monitor starts. The files are read
line by line, ignoring empty lines and lines starting with '#'. All other lines
are sent to the server being promoted, demoted or rejoined. Any error in opening
a file, reading it or executing the contents will cause the entire operation to
fail.

The filed defined in demotion_sql_file is also ran when rejoining a server. This
is to ensure a previously failed master is "demoted" properly when it joins the
cluster.
2018-04-19 17:01:36 +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
50bc43e4bf MXS-1703 Move server-specific diagnostic printing to MariaDBServer 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
c928cf6331 MXS-1703 Fix crash when saving journal without a master server 2018-04-17 10:40:59 +03:00
Esa Korhonen
9b7ec7ee58 MXS-1703 Add missing manual rejoin error messages
Calling rejoin with a server which is already replicating now gives a proper error
message.
2018-04-16 13:52:23 +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
4d6239635e MXS-1703 Add and use convenience functions for common macros/fields
Also add debug assert to MariaDBServer ctor.
2018-04-13 13:31:12 +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
7f36339f53 MXS-1703 Better strtoll() & strtoull() error detection
The functions do not set errno on all invalid input, so it's best to check
endptr.

Also, strtoll is now used for server id scanning through QueryResult.
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