105 Commits

Author SHA1 Message Date
Johan Wikman
11c04ff8a8 MXS-1775 Add disk space threshold to server and monitor
- Instance variable.
- Functions for setting it from configuration file.
2018-06-01 13:48:15 +03:00
Esa Korhonen
c039821467 MXS-1883 Maintenance is now the only user-modifiable bit for a monitored server
The request to turn maintenance off/on is a separate flag, although the actual
status is still contained in the status bitfield.
2018-05-30 10:09:15 +03:00
Markus Mäkelä
0848bedf34
Add comment to static_assert
The C++11 version requires a second parameter.
2018-05-24 12:49:19 +03:00
Esa Korhonen
a2cd4feeaf Store server states as 64-bit to the monitor journal
The journal schema version was changed.
2018-05-24 11:35:34 +03:00
Esa Korhonen
f8940d4a2a Use 64bits for server status flags
Monitor journal still uses 32bits.
2018-05-23 16:19:08 +03:00
Johan Wikman
9d526332d8 MXS-1775 Ensure MonitorInstance::start() returns correct value
Since we need to call mysql_thread_init(), which can fail, in
the monitor thread, we need to wait for the outcome of that
before we can return from start().
2018-05-18 16:00:05 +03:00
Johan Wikman
650a739c92 MXS-1775 Move monitor loop to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
db30ea96f2 MXS-1775 m_master is now a member variable of MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
6db4ce54a9 MXS-1775 MonitorInstance now calls mysql_thread_[init|finish]() 2018-05-18 16:00:05 +03:00
Johan Wikman
15e3a2887c MXS-1775 Move status management to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
1e084b78b1 MXS-1775 MonitorInstance::m_script is now a std::string 2018-05-18 16:00:05 +03:00
Johan Wikman
c7eb0a9958 MXS-1775 Thread starting is now handled by MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
adb7f156d6 MXS-1775 Introduce MonitorInstance::has_sufficient_permissions()
With this function in place, it is now possible to move the thread
starting to MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
3606a5ed1c MXS-1775 Introduce MonitorInstance::configure() function
The configuring of the monitor instance is now performed in a
separate function. That is in preparation for the moving of the
start function to maxscale::MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
bcb7d09a15 MXS-1775 Monitor stopping moved to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
1304fd6147 MXS-1775 Move thread main function to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
3c277f4e5e MXS-1775 Introduce maxscale::MonitorInstance
- All monitors (but MariaDBMon for the time being) inherit
  from that.
- All common member variables moved to that class. Still
  manipulated in derived classes.

In subsequent commits common functionality will be moved to
that class.
2018-05-18 16:00:05 +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
Johan Wikman
bf2a97812d MXS-1848 Destroy all monitors at system shutdown 2018-05-07 14:08:36 +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
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
851cefefc6 MXS-1848 monitor_[alloc|free]() -> monitor_[create|destroy]
As these will call the createInstance and destroyInstance functions
of the monitor, they are more appropriately named like this.
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
83f3d6d71d MXS-1848 Rename monitorDestroy to monitor_deactivate
MonitorDestroy() (renamed to monitor_destroy()) will be used for
actually destroying the monitor instance, that is, execute
destroyInstance() on the loaded module instance and freeing the
the monitor instance.

TODO: monitor_deactivate() could do all the stuff which is currently
      done to the monitor in config_runtime(), instead of just
      turning off the flag.
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
Esa Korhonen
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +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
Markus Mäkelä
b33f464eea
MXS-1506: Make heartbeat reads atomic
The old hkheartbeat variable was changed to the mxs_clock() function that
simply wraps an atomic load of the variable. This allows it to be
correctly read by MaxScale as well as opening up the possibility of
converting the value load to a relaxed memory order read.

Renamed the header and associated macros. Removed inclusion of the
heartbeat header from the housekeeper header and added it to the files
that were missing it.
2018-04-10 15:29:29 +03:00
Markus Mäkelä
f525822472
Merge branch '2.2' into develop 2018-03-20 13:14:54 +02:00
Markus Mäkelä
dcf9d7f152
Fix calls to diagnostics_json
Add missing listener JSON diagnostics call. Check that the
diagnostics_json function exists before calling it.

As the protocol modules don't have diagnostics functions, they aren't
called.

Replace hard-coded strings with constant parameters. This makes it
slightly cleaner.
2018-03-20 13:07:27 +02:00
Esa Korhonen
8ef1385d1a MXS-1703: Turn MariaDB Monitor struct to class with public fields
Allows using std::string for strings. Also, cleanup.
2018-03-07 13:25:52 +02:00
Johan Wikman
236e906d88 Revert "Turn MariaDB Monitor struct to class with public fields"
This reverts commit cb6f70119d9857b277306e9af5881fe29c574a32.
2018-02-24 15:37:50 +02:00
Esa Korhonen
cb6f70119d Turn MariaDB Monitor struct to class with public fields
Allows using std::string for strings. Also, cleanup.
2018-02-21 11:00:42 +02:00
Esa Korhonen
b8d3da4968 Add error tolerance to "servers_no_promotion"
Previously, if the list contained servers that were not monitored by
the monitor yet were valid servers, an error value would be returned
and the monitor failed to start.

With this update, the non-monitored servers are simply ignored when
forming the final list.

Also, added printing of the list to diagnostics.
2018-02-12 10:49:28 +02:00
Esa Korhonen
faaf43ff39 Add gtid to monitor diagnostics, clean up formatting
Gtid:s are now queried every monitor loop.

dignostics() no longer prints slave related info if the server has
no slave connection.
2018-02-10 12:32:56 +02:00
Esa Korhonen
fa8f6a5da3 Fix monitor error with empty servers_no_promotion 2018-02-07 16:11:47 +02:00
Esa Korhonen
1cf3de4a74 Add config parameter for excluding servers from failover
"servers_no_promotion" is a comma-separated list of servers
which cannot be chosen when selecting a new master during failover
(auto or manual), or when automatically selecting a new master
for switchover (currently disabled).

The servers in the list are redirected normally and can be promoted
by switchover when manually selecting a new master.
2018-02-07 14:07:10 +02:00
Esa Korhonen
255250652d Refactor pre-switchover, add similar checks as in failover
Now detects some erroneous situations before starting switchover.
Switchover can be activated without specifying current master.
In this case, the cluster master server is selected.
2018-01-31 10:40:09 +02:00
Markus Mäkelä
396b81f336 Fix in-source builds
The internal header directory conflicted with in-source builds causing a
build failure. This is fixed by renaming the internal header directory to
something other than maxscale.

The renaming pointed out a few problems in a couple of source files that
appeared to include internal headers when the headers were in fact public
headers.

Fixed maxctrl in-source builds by making the copying of the sources
optional.
2017-11-22 18:40:18 +02:00
Markus Mäkelä
07e58444f6 Improve error message for zero monitor timeout values
The error message was not 100% accurate about the value. In addition to
that, neither the value itself nor the monitor or parameter names were
printed in the error message.
2017-11-17 18:05:03 +02:00
Markus Mäkelä
703230a930 Only write monitor journal when it changes
The state of the monitored servers is only persisted if the states of the
servers have changed. This removes the unnecessary disk IO caused by the
writing on the monitor journal.
2017-11-16 15:38:13 +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ä
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ä
2d1e5f46fa Remove use of timestamps in failover code
Using timestamps to detect whether MaxScale was active or passive can
cause problems if multiple events happen at the same time. This can be
avoided by separating events into actively observed and passively observed
events. This clarifies the logic by removing the ambiguity of timestamps.

As the monitoring threads are separate from the worker threads, it is
prudent to use atomic operations to modify and read the state of the
MaxScale. This will impose an happens-before relation between MaxScale
being set into passive mode and events being classified as being passively
observed.
2017-10-27 15:31:46 +03:00
Esa Korhonen
63c7550196 MXS-1490 Prepare for failover functionality addition
Moved mon_process_failover() from monitor.cc to mysql_mon.cc. Renamed
some functions and variables related to previous failover functionality
to avoid confusion.
2017-10-25 12:24:29 +03:00
Markus Mäkelä
582a65f77c Do not return empty relationships
If no relationships of a particular type are defined for a resource, the
key for that relationship should not be defined.
2017-10-23 19:37:24 +03:00
Johan Wikman
df816ea2a9 MXS-1460 Add failover_script parameter
The failover script can now be specified in the configuration file.
2017-10-03 15:24:29 +03:00
Markus Mäkelä
8c3c103060 Merge branch '2.2' into 2.2-mrm 2017-10-03 14:52:21 +03:00
Markus Mäkelä
7ca8db14de MXS-1444: Add monitor parameter alteration
The parameter handling for monitors can now be done in a consistent manner
by establishing a rule that the monitor owns the parameter object as long
as it is running. This will allow parameters to be added and removed
safely both from outside and inside monitors.

Currently this functionality is only used by mysqlmon to disable failover
after an attempt to perform a failover has failed.
2017-10-03 14:50:20 +03:00