5691 Commits

Author SHA1 Message Date
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
Markus Mäkelä
4ee5c991c2 MXS-1452: Extend kill parsing test
The test now correctly checks for usernames and integer overflow.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
96d160f897 MXS-1452: Add support for KILL USER <name>
Added support for killing queries by username. This will kill all
connections from that particular user on all servers.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
4150dee952 Extend KILL parsing test
Added test cases for `KILL [ HARD | SOFT ] [CONNECTION | QUERY ]`.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
49b179bf69 Add HARD/SOFT to executed KILL commands
The HARD and SOFT keywords are parsed and added to the executed KILL
commands.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
4dd6842447 Send KILL commands to backends
KILL commands are now sent to the backends in an asynchronous manner. As
the LocalClient class is used to connect to the servers, this will cause
an extra connection to be created on top of the original connections
created by the session.

If the user does not have the permissions to execute the KILL, the error
message is currently lost. This could be solved by adding a "result
handler" into the LocalClient class which is called with the result.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
a7e610a70a Extract shared session information in LocalClient constructor
When the LocalClient is constructed, it is possible to extract all the
needed information at that time. The only obstacle is the fact that the
LocalClient is constructed at the same time the session is. Since the
client DCB is created before the session, it is safe to extract the shared
data directly from it.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
cd83aa40db Stop monitors first when shutting down
As monitors aren't synchronized with the worker threads, they need to be
shut down first.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
27d1be7f96 Merge branch '2.2' of github.com:mariadb-corporation/MaxScale into 2.2 2017-10-03 14:46:14 +03:00
Markus Mäkelä
bd39284f9c Merge branch '2.1' into 2.2 2017-10-03 14:30:06 +03:00
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
Markus Mäkelä
9280f1a5d7 MXS-1367: Add timeouts for retried queries
The total timeout for the retrying of interrupted queries can now be
configured with the `query_retry_timeout` parameter. It controls the total
timeout in seconds that the query can take.

The actual connection, read and write timeouts of the connector aren't a
good configuration value to use for abstracted queries as the time that it
takes to execute a query can be composed of both connections, reads and
writes. This is caused by the usage of MYSQL_OPT_RECONNECT that hides the
fact that the connector reconnects to the server when a query is
attempted.
2017-10-03 13:03:49 +03:00
Markus Mäkelä
67ef7bd058 MXS-1367: Take mxs_mysql_query into use
The use of a wrapper function allows automated retrying of the queries
without requiring any changes to the code that uses it.
2017-10-03 10:57:12 +03:00
Markus Mäkelä
f1f8a4b5b2 MXS-1367: Retry interrupted queries
The new `query_retries` parameter controls how many times an interrupted
query is retried. This retrying of interrupted queries will reduce the
rate of false positives that MaxScale monitors detect.
2017-10-03 10:57:10 +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ä
1772cc9021 Move blr_set_checksum into blr.h
The function is used in two different files so it needs to be in the
header.
2017-10-02 10:47:27 +03:00
Markus Mäkelä
69557c650e Fix stack trace generation
The stack traces weren't logged as the LOG_ALERT priority wasn't enabled
by default. As an alert is intended to be something that must leave a
trace somewhere, and as such, it must not be possible to disable it. For
this reason, it is acceptable to always log the message if the priority is
LOG_ALERT.

Added the -rdynamic linker flag so that all symbols are exported when
linking MaxScale.

As the stack trace is printed in a signal handler, the first attempt
should be to print the stack trace to the standard output. This way the
output is printed before an attempt to use malloc is made when it is
logged to the logfile.
2017-09-30 12:37:40 +03:00
Markus Mäkelä
94a55f6602 Add missing declaration of blr_set_checksum
The function was used before it was declared.
2017-09-30 08:37: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
MassimilianoPinto
1827f042e8 MXS-1459: Assign binlog checksum value at startup
Binlog checksum default value is wrong if a slave connects with
checksum = NONE before master registration or master is not accessible
at startup
2017-09-29 18:57:09 +02: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ä
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
MassimilianoPinto
32709b3e46 MXS-1458: Mark backend server as inactive if router is not configured.
MXS-1458: Mark backend server as inactive if router is not configured.
2017-09-28 10:01:29 +02: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ä
016ad77b62 MXS-1457: Inject service credentials if no users are loaded
If the authenticator option is enabled, no users are loaded and no errors
have occurred in the user loading process, the service credentials are
injected.
2017-09-27 20:00:39 +03:00