8787 Commits

Author SHA1 Message Date
Johan Wikman
267a45ad63 MXS-1441 Add switchover_script parameter
If a switchover_script parameter is given, its value will be used as
the switchover script. Otherwise the default will be used. Currently
just echo.

The MySQL Monitor now introduces two script variables, CURRENT_MASTER
and NEW_MASTER, that contain information about the current and new
master respectively.

Switchover is performed only if switchover has been enabled and MaxScale
is *not* in passive mode.
2017-10-03 13:51:08 +03:00
Johan Wikman
17c3d1e612 MXS-1441 Make externcmd_allocate const correct 2017-10-03 10:45:37 +03:00
Johan Wikman
cf0a87e7f2 MXS-1441 Expose monitor_launch_command
So that a specific monitor may create the command and replace
monitor specific script variables before giving the command
for execution.
2017-10-03 10:32:42 +03:00
Johan Wikman
8d1c4bdd56 MXS-1441 Use monitor_launch_script for performing switchover
To be able to do that, we need to get hold of the MXS_MONITORED_SERVER
corresponding to the SERVER specified as the new master.

So, instead of just return a boolean indicating whether the server was
found or not we return the MXS_MONITORED_SERVER pointer.
2017-10-03 09:28:42 +03:00
Johan Wikman
e295d438d4 MXS-1441 Expose monitor_launch_script
So that it can be called directly from a monitor.
2017-10-03 09:19:23 +03:00
Johan Wikman
f29d8209cc MXS-1441 Create proper json error objects 2017-10-02 16:08:12 +03:00
Johan Wikman
e41f60fd2e Add mxs_json_error_append
Using this function, more error object can be added to the error
array of an json error object.
2017-10-02 16:08:12 +03:00
Johan Wikman
438b4e0341 Merge branch '2.2' into 2.2-mrm 2017-10-02 15:49:08 +03:00
Johan Wikman
68432bbaa3 Rename MXS_MONITOR::databases to MXS_MONITOR::monitored_servers
More descriptive name. Some local varaibles could now also be
renamed to be more descriptive, but that's for another day.
2017-10-02 15:33:58 +03:00
Johan Wikman
8d03876e3e Rename MXS_MONITOR_SERVERS to MXS_MONITORED_SERVER
An element in a linked list is not a list.
2017-10-02 15:05:17 +03:00
Markus Mäkelä
27ccf0877c Fix bug in the cdc_connector
The cdc_connector did not check if the data request was successful.
2017-09-29 21:11:12 +03:00
Markus Mäkelä
b446f442b6 Process data sent before authentication is complete
If the client sends data before authentication is complete, it must not be
discarded and it needs to be processed like as if it was sent in a
separate network packet.
2017-09-29 21:11:08 +03:00
Markus Mäkelä
c6623337b6 Stop monitors first when shutting down
As monitors aren't synchronized with the worker threads, they need to be
shut down first.
2017-09-29 21:11:07 +03:00
Johan Wikman
a81d85fba2 MXS-1441 Add switchover logic
Switchover expects one or two servers as argument, one (the new
master) if there is no master and two (the new master, and the
current master) if there currently is a master.

The procedure is as follows:
- Stop monitor
- Check that provided arguments are reasonable.
  - If there is no master currently, then only one argument is
    accepted.
  - If there is a master, then it must also be specified.

  This is to prevent pathological cases where the situation has
  changed after the admin has issued the switchover command.
- Check the failover mode and disable it.
- Perform the failover.
- If succeeded, enable failover if it was.
- If it failed, if failover was enabled, do not enable it and log
  an alert. If failover was not enabled, just log an error.
2017-09-29 16:19:12 +03:00
Johan Wikman
f87a878073 Set monitor state before thread launch
When the monitor is started, the state is immediately updated
to running, and not only when the thread actually has started
executing.
2017-09-29 13:10:49 +03:00
Johan Wikman
4aea1b6150 Always return json object from module commands
If a module command returns a json object, it will always be
returned to the caller, irrespective of whether the command
itself succeeded or not.

Otherwise, if the command failed and if the module command has
set an error message, that error message will be returned as a
json object containing the error message.
2017-09-29 13:10:29 +03:00
Markus Mäkelä
41938a205f Fix formatting errors
Fixed the formatting errors introduced by Astyle. Changed the comment
syntax to use a more Astyle-friendly one.
2017-09-29 13:10:29 +03:00
Johan Wikman
ae3e7a07e2 Always return json object from module commands
If a module command returns a json object, it will always be
returned to the caller, irrespective of whether the command
itself succeeded or not.

Otherwise, if the command failed and if the module command has
set an error message, that error message will be returned as a
json object containing the error message.
2017-09-29 12:06:17 +03:00
Markus Mäkelä
071d364b0a Fix formatting errors
Fixed the formatting errors introduced by Astyle. Changed the comment
syntax to use a more Astyle-friendly one.
2017-09-28 20:27:07 +03:00
Johan Wikman
89d1f81e37 Merge branch '2.2' into 2.2-mrm 2017-09-28 15:19:20 +03:00
Johan Wikman
9c60b68476 Convert mysql_mon.c to mysql_mon.cc 2017-09-28 15:17:27 +03:00
Markus Mäkelä
14d8b6a0df Remove MODULECMD_ARG_OUTPUT argument type
Since the module command interface was expanded to include a JSON output
parameter, there is no longer a need for an output DCB. As the JSON can be
printed by both maxadmin and the REST API, this allows the removal of
explicit output formatting in module commands.
2017-09-28 13:59:28 +03:00
Markus Mäkelä
da648387dd Handle failed module commands with no error messages
If a module command fails to execute but no error messages are stored, a
generic error message is logged.
2017-09-28 13:53:40 +03:00
Johan Wikman
ff467e218a MXS-1441 Add switchover and switchover_timeout config vars
Tentative documentation.

With the 'switchover' config variable the switchover functionality
can be enabled. If enabled a REST API endpoint will appear, using
which that switchover can be initiated.

Switchover can only be performed when MaxScale is in active mode
and failover will be disabled for the duration of the switchover.
Only if the switchover succeeds, will failover be enabled again.

Might be easier to expose that REST API always and only change
the behaviour when calling it, instead of making it appear and
re-appear.
2017-09-28 13:29:21 +03:00
Markus Mäkelä
380482d507 Fix memory leak on module command call
If a module command outputted JSON, the string generated by json_dumps
would leak.
2017-09-28 13:11:49 +03:00
Markus Mäkelä
e55968b808 Fix listener creation via REST API
The check for SSL parameters was wrong as it tested whether all SSL
parameters were defined even when the check was not needed.
2017-09-28 13:03:04 +03:00
Markus Mäkelä
f102a563e9 Add explicit usage to each command
The yargs framework combined with the pkg packaging causes the executable
name to be mangled on installation. For this reason, the usage should be
explicitly added to each command.
2017-09-28 12:40:51 +03:00
Markus Mäkelä
c2283bbff1 Remove LocalClient fd from poll set
The file descriptor registered for the LocalClient instances need to be
removed from the worker it was added to when the object is destroyed.
2017-09-28 11:04:02 +03:00
Markus Mäkelä
5b0b1666cc Fix bug649
The `Test` is a pointer.
2017-09-28 10:39:37 +03:00
Markus Mäkelä
d4fd34cecd MXS-1446: Move failover parameters into mysqlmon
The `failover` and `failover_timeout` parameters are now declared as a
part of the mysqlmon module. Changed the implementation of the failover
function so that the dependencies on the monitor struct can be removed or
moved into parameters.
2017-09-28 08:23:34 +03:00
Markus Mäkelä
ef115208e6 MXS-1446: Move failover to mysqlmon
Split the state change processing and failover handling into two separate
functions and added a call to the failover function into mysqlmon. This
prevents unintended behavior when failover is enabled for non-mysqlmon
monitors. The parameter itself still needs to be moved into mysqlmon.

Moved the failover documentation to the mysqlmon documentation as it is
specific to this monitor.
2017-09-28 07:54:42 +03:00
Markus Mäkelä
895d950da0 Format all source files with Astyle
Formatted all source files Astyle.
2017-09-28 07:04:21 +03:00
Markus Mäkelä
8fd8c30cd0 Add support for KILL [HARD|SOFT]
The keywords HARD and SOFT are now ignored.
2017-09-27 20:35:34 +03:00
Markus Mäkelä
0d6c06f33d MXS-1446: Add heartbeat conversion macros
The macros make the conversion from heartbeats to seconds more convenient
and consistent.
2017-09-27 19:44:25 +03:00
Markus Mäkelä
667440fbef MXS-1446: Calculate the monitor event only once
As the monitor event is now stored in the server, it can be re-used when
the event is converted to string form. This also fixes the problem of
state calculation taking place when the event happened in the past.
2017-09-27 19:44:25 +03:00
Markus Mäkelä
4c3d6f6884 MXS-1446: Add execution of dummy failover command
The failover command is simulated by executing a call to /usr/bin/echo
with all possible monitor parameters. This allows testing of the failover
mechanism without actually using the failover command.
2017-09-27 19:44:21 +03:00
Markus Mäkelä
316f792242 MXS-1446: Make failover_timeout configurable
The time that MaxScale waits for a failover is now configurable.
2017-09-27 19:37:41 +03:00
Markus Mäkelä
4c6e7a0dbc MXS-1446: Add preliminary documentation for passive
The documentation only hints at the actual implementation and it needs to
be extended once the implementation details are known.
2017-09-27 19:32:58 +03:00
Markus Mäkelä
ef2ee38ccf MXS-1446: Store more detailed event information
The timestamp of the last change from passive to active is now
tracked. This, with the timestamps of the last master_down and master_up
events, allows detection of cases when MaxScale was failed over but the
failover was not done.

Currently, only a warning is logged if no new master has appeared within
90 seconds of a master_down event and MaxScale was set to active from
passive.

The last event and when the event was triggered is now shown for all
servers. The latest change from passive to active is also shown.
2017-09-27 19:32:58 +03:00
Markus Mäkelä
3e1d89ff17 MXS-1446: Store last triggered event for each server
When an event occurs on a server, it is now stored so that the last event
for each server is known. This allows a state change to trigger an event
even if, at the time of the event, no action was taken.

This change is only cosmetic as no functionality is implemented.
2017-09-27 19:32:58 +03:00
Markus Mäkelä
1d2ba10a68 MXS-1446: Add passive parameter
The `passive` parameter can be given in the configuration file or on the
command line. It is displayed in the diagnostic output and changes to it
are persisted.

The variable itself does nothing.
2017-09-27 19:32:58 +03:00
Markus Mäkelä
bc510a1ad9 MXS-1446: Minor refactoring of gateway.cc
Cleaned up parts of the main function and moved the global configuration
initialization to the very beginning of the main function.
2017-09-27 19:32:58 +03:00
Markus Mäkelä
ab2286235f Merge branch '2.2' into 2.2-mrm 2017-09-27 19:32:39 +03:00
Markus Mäkelä
39c19e1bb9 Fix memory leak on loading of users
If the new format users are loaded, the loaded JSON object was never
freed.
2017-09-27 19:26:05 +03:00
Markus Mäkelä
3922f7a901 Enable tee filter tests for 2.2
Enabled the tests that were accidentally disabled and cleaned up some of
the redundant code in bug649.
2017-09-27 19:26:05 +03:00
Markus Mäkelä
f20005dddc Add missing parameters to alter monitor
The `script_timeout` and `journal_max_age` parameters weren't handled in
the monitor alteration code.

Also added missing documentation to maxadmin help output for
`alter monitor`.
2017-09-27 19:26:05 +03:00
Johan Wikman
886deb9682 Merge branch '2.2' into 2.2-mrm 2017-09-27 13:08:24 +03:00
Johan Wikman
7b6680b8fa Merge branch '2.1' into 2.2 2017-09-27 13:04:14 +03:00
Johan Wikman
e97f26f170 Add MaxScale 2.1.10 release notes
Update change log and upgrading as well.
2017-09-27 12:59:20 +03:00
Johan Wikman
23fb0bf928 MXS-1449 Firewall: Allow 'USE <db>'
When the database firewall filter is used in white-list mode,
'USE <db>' should be allowed. When connecting, it is always
possible to specify the database anyway so restricting
'USE <db>' serves no purpose.
2017-09-27 12:59:20 +03:00