Commit Graph

167 Commits

Author SHA1 Message Date
5172c43e29 MXS-1775 Add functions for checking disk space of servers 2018-06-06 15:25:57 +03:00
70fdd0fc17 Merge branch '2.2' into develop 2018-06-06 08:56:31 +03:00
f2b2951c99 Track the number of performed monitoring intervals
Tracking how many times the monitor has performed its monitoring allows
the test framework to consistently wait for an event instead of waiting
for a hard-coded time period. The MaxCtrl `api get` command can be used to
easily extract the numeric value.
2018-06-06 08:46:46 +03:00
7cd19a12a2 MXS-1883 Remove locking during monitor loop
Since the admin cannot modify server states any more, the locks are not
required.
2018-06-01 15:03:07 +03:00
e8deb553be MXS-1775 Make MonitorInstance more resilient towards abuse
If MonitorInstance is in the wrong state when it is started/stopped
a warning is logged and the operation ignored.
2018-06-01 13:48:15 +03:00
a55019774d MXS-1775 Expose the state of the monitor 2018-06-01 13:48:15 +03:00
ebcb807438 MXS-1775 Add default implementations 2018-06-01 13:48:15 +03:00
9b7e37e112 MXS-1775 Change MonitorInstance::configure() prototype
Now return boolean, to allow derived class to signal a failure
to configure.
2018-06-01 13:48:15 +03:00
0833db8a48 MXS-1775 Flush pending status to servers using common code 2018-06-01 13:48:15 +03:00
15b1c270a3 MXS-1775 Check connection in MonitorInstance::tick()
Since the connection checking is done in an identical fashion in
all monitors, it can be moved to the base-class.
2018-06-01 13:48:15 +03:00
df4e19eb27 MXS-1775 Provide default implementation for MonitorInstance::tick 2018-06-01 13:48:15 +03:00
af9beecaef MXS-1775 Handle config param disk_space_check_interval 2018-06-01 13:48:15 +03:00
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
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
0848bedf34 Add comment to static_assert
The C++11 version requires a second parameter.
2018-05-24 12:49:19 +03:00
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
f8940d4a2a Use 64bits for server status flags
Monitor journal still uses 32bits.
2018-05-23 16:19:08 +03:00
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
650a739c92 MXS-1775 Move monitor loop to MonitorInstance 2018-05-18 16:00:05 +03:00
db30ea96f2 MXS-1775 m_master is now a member variable of MonitorInstance 2018-05-18 16:00:05 +03:00
6db4ce54a9 MXS-1775 MonitorInstance now calls mysql_thread_[init|finish]() 2018-05-18 16:00:05 +03:00
15e3a2887c MXS-1775 Move status management to MonitorInstance 2018-05-18 16:00:05 +03:00
1e084b78b1 MXS-1775 MonitorInstance::m_script is now a std::string 2018-05-18 16:00:05 +03:00
c7eb0a9958 MXS-1775 Thread starting is now handled by MonitorInstance 2018-05-18 16:00:05 +03:00
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
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
bcb7d09a15 MXS-1775 Monitor stopping moved to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
1304fd6147 MXS-1775 Move thread main function to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
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
b29bae6e84 MXS-1865 Update server version only when (re)connecting
Updating it every iteration is needless.
2018-05-16 13:55:45 +03:00
bf2a97812d MXS-1848 Destroy all monitors at system shutdown 2018-05-07 14:08:36 +03:00
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
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
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
510eb7ec7c MXS-1848 Change monitorCamelCase to monitor_snake_case 2018-05-07 14:08:36 +03:00
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
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
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
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
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
f525822472 Merge branch '2.2' into develop 2018-03-20 13:14:54 +02:00
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
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
236e906d88 Revert "Turn MariaDB Monitor struct to class with public fields"
This reverts commit cb6f70119d9857b277306e9af5881fe29c574a32.
2018-02-24 15:37:50 +02:00
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
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
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
fa8f6a5da3 Fix monitor error with empty servers_no_promotion 2018-02-07 16:11:47 +02:00
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
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