5691 Commits

Author SHA1 Message Date
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ä
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ä
395b445336 MXS-1457: Ignore removed servers when loading users
When users are loaded, removed or deleted servers are ignored.
2017-09-27 19:28:05 +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ä
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
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
Johan Wikman
c1a7008479 MXS-1449 Sort case statements
Faster to later check for something specific.
2017-09-27 12:59:20 +03:00
Markus Mäkelä
f06c34f66c MXS-1456: Fix crash on empty script value
If a script variable resolves to an empty string, the replacement attempt
will fail with an out-of-memory error. The following realloc call will
fail as it requires a positive value for the new size.
2017-09-27 10:32:26 +03:00
Johan Wikman
c706841cd7 Merge branch '2.2' into 2.2-mrm 2017-09-26 14:31:32 +03:00
Markus Mäkelä
2633ad2fe4 Merge branch '2.1' into 2.2 2017-09-26 14:29:14 +03:00
Johan Wikman
df4f3cb302 MXS-1450 Remove leading whitespace
Leading whitespace is removed from a sent maxadmin command
before the command is interpreted.
2017-09-26 13:47:08 +03:00
Johan Wikman
bfe387b73f MXS-1450 Remove manual history, sort includes
Remove manually maintained revision history and sort include
files.
2017-09-26 13:43:59 +03:00
Johan Wikman
4220e3ca6a MXS-1450 Add more string trimming functions
- trim_leading
- trim_trailing

Implemented trim in terms of trim_leading and trim_trailing
2017-09-26 13:36:10 +03:00
Johan Wikman
bb95074e88 MXS-1450 Add test case for trim 2017-09-26 13:19:09 +03:00
Markus Mäkelä
2079bba49c MXS-1451: Calculate password even with skip_authentication=true
The result of the authentication should be ignored but the scramble that
is calculated as a side-effect still needs to be stored. This can be done
by altering the SQL used to get the matching row to only match on the
username, not the network address.

Also expanded the test case to cover the use of bad credentials.
2017-09-25 19:00:44 +03:00
Johan Wikman
f6380a09c7 Merge branch '2.2' into 2.2-mrm 2017-09-25 12:38:32 +03:00
Markus Mäkelä
551bfb6f26 Merge branch '2.1' into 2.2 2017-09-25 12:35:11 +03:00
Johan Wikman
758319ed23 Merge branch '2.2' into 2.2-mrm 2017-09-25 11:04:24 +03:00
Markus Mäkelä
25f9cc14b4 Update avrorouter and the related tutorial
The avrorouter now uses the parameters from the source service. This
removes the need for redundant parameter definition in the avrorouter
service when they are defined in the binlogrouter service as parameters.

Added some missing configuration sanity checks and updated the tutorial to
reflect the new configuration method introduced in 2.1.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
45b78a795e Update binlogrouter defaults
The documentation stated that the binlogrouter would use the cache
directory to store the binary log files. In reality, there was no default
value and the service would fail to start without a binlogdir parameter.

The router now uses the data directory (/var/lib/maxscale/) to store the
binary logs.

Set the default value of mariadb10-compatibility to true. This is in line
with the fact that most installations should use the router with a MariaDB
10.0 server or newer.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
944a5bd9c1 Only extract successful PS responses
If a prepared statement fails to execute on a backend server, no prepared
statement ID is returned. As the connection to the slave backend will be
closed when the result of a session command differs from the master's
response, there's no need to even attempt extracting the response.

This change avoids the triggering of a false positive in
mxs_mysql_extract_ps_response when an attempt to extract a
COM_STMT_PREPARE response is made on a response that isn't a
COM_STMT_PREPARE response.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
7082edc4ed Also extract SQL from COM_STMT_PREPARE
COM_STMT_PREPARE contains the plain-text prepared statement so it can be
extracted as if it were a COM_QUERY command.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
2d590308b6 Set current command when executing queued queries
When readwritesplit is routing any queued queries, the currently executed
command of the protocol modules needs to be adjusted by
readwritesplit. This is not a true fix but more of a workaround to fix the
problems of queued query execution.

The correct solution would be to move the queued query handling into the
client protocol module so that all components see the same state.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
bfeaceb070 Assert that only complete COM_STMT_PREPARE responses are returned
Asserting that only a complete COM_STMT_PREPARE is returned when the
prepared statement preparation is extracted will guarantee that the
protocol works as expected.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
30f92ebb4b Only pre-process the current statement
If a statement is about to be queued, there's no need to fully parse it
when it will be done again once the current command being executed
finishes.
2017-09-25 10:46:55 +03:00
Markus Mäkelä
fbc1a7d44b Fix handling of multi-packet queries in readwritesplit
If a prepared statement sends large amounts of data, the target server
where the data is sent will be tracked. The tracked target was not reset
after a multi-packet query was completed and the target itself was used to
check whether the session was processing a multi-packet query.

Changed the check to use the boolean variable instead of the target and
added a reset of the tracked target after a multi-packet query was
completed.
2017-09-25 10:46:44 +03:00
Johan Wikman
56b947b27d MXS-1445: Provide credentials to scripts
If an invoked script must access servers, it needs credentials.
When invoked, a script can now be provided with the monitor
credentials of MaxScale using the variable CREDENTIALS.

It will be expanded like

    user:password@[...]:N1,user:password@[...]:N2

for every server the monitor in question is monitoring. That is,
irrespective of whether it is a master or a slave, running or not.

Thus, a failover script could be specified like:

  [MyMonitor]
  type=monitor
  module=mysqlmon
  ...
  script=.../failover.sh --credentials=$CREDENTIALS --slaves=$SLAVELIST
  events=master_down

Note, it may make sense to introduce specific failover (and switchover)
keywords, but with the above addition it is possible to start
experimenting with failover scripts.
2017-09-22 13:54:14 +03:00
MassimilianoPinto
845b59ad48 Fix buffer size for testbinlog.c
Fix buffer size for testbinlog.c
2017-09-21 11:01:55 +02:00
Markus Mäkelä
eb3a9667fc Discard connections on interrupted COM_CHANGE_USER
Close the connection if a COM_QUIT is received while the COM_CHANGE_USER
is in progress.
2017-09-21 09:25:56 +03:00
MassimilianoPinto
825e1478a1 MXS-1423: CHANGE MASTER TO tests with GTID option set
MXS-1423: CHANGE MASTER TO tests with GTID option set
2017-09-20 10:44:19 +02:00
Markus Mäkelä
9046db06c5 MXS-1295: Add strict_sp_calls parameter
The new parameter allows the session to be "locked" to the master server
after a stored procedure is called. This will keep the session state
consistent if the stored procedure call modifies the state of the session.
2017-09-20 11:18:16 +03:00
Johan Wikman
1b009f94cf Merge branch '2.1' into develop
MXS-1377
2017-09-20 11:08:48 +03:00
Johan Wikman
9d9cffe4c7 MXS-1377 Always delete the pid-file
Earlier the pid-file was deleted only if the MaxScale startup
succeeded and MaxScale exited in normal fashion.
2017-09-20 10:57:13 +03:00
Markus Mäkelä
68bcd00a22 Merge branch '2.1' into develop 2017-09-20 10:47:53 +03:00
Johan Wikman
3936c71e11 Add missing includes 2017-09-19 15:46:13 +03:00
Markus Mäkelä
364789abde MXS-1404: Add experimental Group Replication monitor
The monitor performs simple monitoring of a group replication cluster. It
expects no extra parameters in addition to the common monitor parameters
and will only set master and slave status bits on the servers. It is a
part of the experimental package as it is a very experimental module.

Further improvements would be to add the usage of the synced state.
2017-09-19 09:50:29 +03:00
Markus Mäkelä
aaa60d37e6 Add missing parameter documentation to maxrows
Documented new parameters.
2017-09-18 22:03:30 +03:00
Markus Mäkelä
d72375ebb5 Reset resultset offset when discarding response
The offset into the resultset buffer needs to be reset before each
processed packet if the resultset is being discarded.
2017-09-18 20:51:52 +03:00
Markus Mäkelä
d168493ddf Fix maxrows offset calculation
The code that handles the resultset rows added the extra offset given as a
parameter into the total offset when it should've be ignored.
2017-09-18 20:32:28 +03:00
Markus Mäkelä
ab777c76c7 Add CHILDREN to monitor scripts
The CHILDREN parameter expands to a list of server IPs and ports that are
direct descendants of the server that initiated the event.

Also added a note that the variables can expand to empty strings if
nothing matches the criteria of the variable.
2017-09-18 13:12:17 +03:00
Markus Mäkelä
9080072de5 Add PARENT variable to monitor scripts
The scripts now replace the PARENT variable with the IP and port of the
server that is the direct parent node of the server that initiated the
event. For master-slave clusters, this will be the master IP if the server
that triggered the event is a slave.
2017-09-18 13:00:02 +03:00