7601 Commits

Author SHA1 Message Date
Markus Mäkelä
5f83b07fc2
MXS-2241: Detect invalid readwritesplit configuration
master_reconnection and disable_sescmd_history are, in practice, mutually
exclusive settings.
2019-01-07 11:06:24 +02:00
Markus Mäkelä
0859f3caff
Merge branch '2.2' into 2.3 2019-01-07 10:33:34 +02:00
Markus Mäkelä
46bea87ff6
MXS-2238: Fix reading of large Avro schemas
The schemas were read incorrectly which resulted in large schemas having
multiple newlines in them.
2019-01-06 13:05:42 +02:00
Markus Mäkelä
8c437c6440
Fix crash in galeramon
An std::string was assigned a null value which will cause a crash.
2019-01-04 12:00:48 +02:00
Markus Mäkelä
fe4c848079
Use direct access into strings while canonicalizing
The process of appending to a std::string always includes a size check in
case the internal storage needs to expand. Given that we know a
canonicalized version of a query string is never larger than the original
string and that we pre-allocate enough memory to cope with the worst-case
scenario, the extra logic in std::string::push_back is unnecessary and an
extra cost. Writing directly into the string avoids this cost and improves
the performance.
2019-01-03 21:37:11 +02:00
Markus Mäkelä
ad5b244313
Optimize canonicalization code
Switched from default character type functions to ones that use lookup
tables. Eliminated the internal state and replaced with in-place iteration
of the query. Added code to allow single-lookup detection of normal
characters.
2019-01-03 21:37:11 +02:00
Markus Mäkelä
87c3b1d25b
MXS-2234: Extend persisted config file log message
The log message should now contain enough information to more easily debug
any configuration issues that result from updating the main config file
after runtime changes have been done.

Also fixed the theoretical race condition in detection of persisted
configuration files by only checking for their existence once.
2019-01-03 12:48:30 +02:00
Markus Mäkelä
9adbd2f8f0
Cache the local server statistics object
By storing the server statistics object in side the session, the lookup
involved in getting a worker-local value is avoided. Since the lookup is
done multiple times for a single query, it is beneficial to store it in
the session.

As the worker-local value is never deleted, it is safe to store a
reference to it in the session. It is also never updated concurrently so
no atomic operations are necessary.
2019-01-03 09:37:59 +02:00
Markus Mäkelä
1fa3b133c7
Make keepalive ping checks more efficient
The code now only checks the need for a keepalive ping once every
keepalive interval. Reduced the number of mxs_clock calls to one so that
all servers use the same value.
2019-01-03 09:37:59 +02:00
Markus Mäkelä
050ce7f1a3
MXS-2200: Add runtime handling for all global parameters
All global parameters are now handled by the runtime configuration
modification code. The parameters that are trivial to update can now be
updated at runtime. All other global parameters cause a new error message
to be returned stating that the parameter in question cannot be modified
at runtime.

Also updated the list of modifiable parameters in MaxCtrl. This list
should not be stored in MaxCtrl and should be created by MaxScale at
runtime.
2019-01-03 09:37:59 +02:00
Markus Mäkelä
ee98900685
MXS-2200: Extend REST API tests
Added test cases for static and unknown global parameters.
2019-01-03 09:37:59 +02:00
Markus Mäkelä
26da72a41f
Merge branch '2.2' into 2.3 2019-01-03 09:23:16 +02:00
Markus Mäkelä
8f0e4a3034
MXS-2232: Fix version string prefix check
The prefix was always added even when the original version would've been
acceptable. For example, a version string of 5.5.40 would get converted to
5.5.5-5.5.40 which is quite confusing for older client applications.
2019-01-02 19:29:48 +02:00
Markus Mäkelä
04dd05b262
MXS-2231: Move TLS handshake code into MariaDBClient
The code is now in the correct place and TLS connections with all
authenticators should now work.
2019-01-02 19:29:41 +02:00
Markus Mäkelä
edd03e950f
MXS-2209: Use compound roles only with 10.2.15+
Due to MDEV-15556 and MDEV-15840 recursive CTEs can't be reliably used
with older 10.2 versions. To prevent problems, only use the query that
extracts composite roles with newer versions.
2019-01-02 19:27:14 +02:00
Markus Mäkelä
35d31801bb
Merge branch '2.2' into 2.3 2018-12-17 23:52:56 +02:00
Markus Mäkelä
208a1d011e
Pre-allocate return value in get_canonical
Since we know the worst-case size of a canonical statement is the size of
the query string, we can reduce the number of memory allocations to one in
the get_canonical function.
2018-12-17 23:16:01 +02:00
Niclas Antti
f2a3a5737a MXS-2221 Fatal signal handling does not always create a core
Quick and simple fix, but this should be overhauled. See MXS-599.
2018-12-11 14:22:35 +02:00
Markus Mäkelä
48efa6d027 MXS-2213: Clear stored PS information
The information stored for each prepared statement would not be cleared
until the end of the session. This is a problem if the sessions last for a
very long time as the stored information is unused once a COM_STMT_CLOSE
has been received.

In addition to this, the session command response maps were not cleared
correctly if all backends had processed all session commands.
2018-12-11 13:54:10 +02:00
Markus Mäkelä
8b00a00ea7 MXS-2216: Use correct function in response processing
When a response to a prepared statement was processed, the number of EOF
packets was used to see whether the response was complete. This code used
a function that does not work with the special packet returned by a PS
preparation that is similar to an OK packet.

The correct method is to count the total number of packets in the
response.
2018-12-11 13:54:10 +02:00
Markus Mäkelä
1126c687a4
Fix alloc-dealloc mismatch in qc_classify_as_json
The deleter for std::unique_ptr<GWBUF> was not included in that file which
caused it to be deleted with the default deleter. The same should apply to
std::unique_ptr<json_t> as well.
2018-11-29 11:25:28 +02:00
Johan Wikman
9b571566aa Fix crash in maxadmin show filter 2018-11-28 19:34:18 +02:00
Markus Mäkelä
7331549915 MXS-2188: Update target table in prepare_table
Passing the target table and create to the prepare_table function allows
the converter to update the internal variables.
2018-11-28 19:32:52 +02:00
Markus Mäkelä
1802151c62 Fix blr server protocol name
The server that the binlogrouter creates used the old protocol name that
caused a confusing deprecation warning.
2018-11-28 19:32:31 +02:00
Johan Wikman
cf66cc6968 Merge branch '2.2' into 2.3 2018-11-28 11:27:44 +02:00
Markus Mäkelä
6451b1f21a
MXS-2183: Fix memory leaks
Under heavy load some of the basic network operations could fail which led
to some of the allocated memory to leak.

Also the backend protocol never freed the current protocol command if it
was not completed. This would happen if a user executed a session command
as the first command but backend authentication would fail.
2018-11-28 02:03:00 +02:00
Markus Mäkelä
24d1876ed4
Initialize memory in password hashing
The authentication code did not initialize one of the buffers used to
calculate the password hashes. This resulted in the use of uninitialized
memory when the user provided no password.
2018-11-28 00:15:57 +02:00
Markus Mäkelä
da83551493
MXS-2189: Prevent unwanted trx replay
When a transaction is being executed on a slave and the master fails, the
transaction replay would start.
2018-11-27 12:52:45 +02:00
Markus Mäkelä
05c9aea04d
MXS-2186: Make SHOW DATABASES a read
Since SHOW TABLES is a read, SHOW DATABASES should be one as well.
2018-11-27 12:52:44 +02:00
Markus Mäkelä
1abcbd64bd
MXS-2187: Allow multiple transaction retries
By resetting the replay state the transaction replay can start again on a
new server. This allows the replay process work when a master server is
shutting down.
2018-11-27 12:52:44 +02:00
Markus Mäkelä
e6325d39fb
Delay initial transaction replay
By delaying the replay for a second, we give the monitor a small chance to
adap to master failures. It'll also prevent rapid re-querying if multiple
transaction replays are supported.
2018-11-27 12:52:44 +02:00
Markus Mäkelä
851793cb86
Fix transaction replay debug assertion
A transaction that just completed will go through the start_trx_replay
function as from the client protocol's point of view the transaction is
still open. The debug assertion did not take this into account and would
fail if a successful commit was the last thing done on master that failed.

Also fixed the formatting.
2018-11-27 12:52:44 +02:00
Markus Mäkelä
81937c635b
Fix current command tracking during LDLI
When a LOAD DATA LOCAL INFILE was executed, the client and backend
protocols would update the command byte leading to misinterpretations of
the data.
2018-11-27 12:52:44 +02:00
Markus Mäkelä
f87ff431c1
Merge branch '2.2' into 2.3 2018-11-27 11:46:47 +02:00
Markus Mäkelä
f41caae5c7
MXS-2175: Fix available_when_donor
If a Galera cluster drops down to a single node, the last node would not
be considered valid. During the failure of the second to last node, the
master would also temporarily lose the master status.

The behavior was changed to always keep the cluster UUID until the cluster
size drops down to zero. This guarantees that the same cluster is used as
long as possible.
2018-11-27 09:22:39 +02:00
Markus Mäkelä
a042ad646b
MXS-2184: Fix avrorouter GTID generation
The event number in the GTID was not incremented for the update_after part
of the transaction.
2018-11-26 09:42:12 +02:00
Markus Mäkelä
842f9f1d15
Fix transaction replay timeout
The timeout would not be triggered due to the fact that the
delayed_retry_timeout wasn't inspected.
2018-11-26 09:42:12 +02:00
Markus Mäkelä
7bf5c07835
Ignore errors sent by servers in shutdown
When a server is stopping, it'll send an error to the client before
terminating the TCP connection. The code in readwritesplit would detect
this error and create a hangup event on the DCB. This would cause it to
appear as if the TCP connection was broken and the router would
immediately try to reconnect to the same server.

By ignoring the error and allowing the connection to die on its own, we
avoid immediately reconnecting and retrying any transactions on the
stopping server. This increases the chances that the monitor will see it
first and assign the server states correctly before the transaction replay
is attempted.
2018-11-26 09:42:12 +02:00
Markus Mäkelä
9f6700b329
Skip connection_keepalive during transaction_replay
When a transaction is replayed, there is no target but the routing was
"successful".
2018-11-26 09:42:11 +02:00
Markus Mäkelä
925670ae2f
Fix false master failure log message
The message would be logged even if the session continues.
2018-11-26 09:42:11 +02:00
Markus Mäkelä
8b92c63248
Remove incorrect assertion
The assertion would hold true for a single worker but it can't be
guaranteed to be true on a multi-worker system where the statistics are
distributed across the workers.
2018-11-26 09:42:11 +02:00
Markus Mäkelä
dcf53da209
Enable connection_keepalive by default
Enabling the feature by default prevents the master connection from dying
during times when there are very little or no writes. Having a modest ping
interval of 300 seconds serves to minimize the amount of extra work that
both MaxScale and the server have to do while still keeping the
connections in good shape.
2018-11-26 09:42:11 +02:00
Esa Korhonen
b47d4a4105 Use max_statement_time
Used only with supporting server versions. Using the time limit ensures that
the server interrupts the query at the same point Connector-C would cut the
connection. This prevents lingering queries.

Also, cleans up some associated error messages.
2018-11-23 15:15:44 +02:00
Esa Korhonen
0a5a3309e0 Add missing quotes when printing server names
Some of the log messages didn't have the quotes.
2018-11-23 14:02:09 +02:00
Esa Korhonen
fb52e565fe Store capabilities of monitored server
Checking the version number in various places in the code gets confusing.
It's better to check the version in one place and record the relevant data.
2018-11-21 17:36:52 +02:00
Esa Korhonen
01628dd0de Cleanup server version updating 2018-11-21 17:36:52 +02:00
Johan Wikman
1591ff7f46 MXS-2179 Activate WD workaround when fetching users
Fetching the users may potentially take longer than the watchdog
timeout. To ensure that MaxScale is not killed by systemd, we must
ensure that the notifications are generated also when MaxScale
synchronously is fetching the users.
2018-11-21 13:47:04 +02:00
Johan Wikman
f1a113aff0 MXS-2178 Reduce accessbility of workarounds
Some rearrangements to ensure that what should be private
can be kept private.

- WatchdogNotifier made a friend.
- WatchdogWorkaround defined in RoutingWorker and made a friend.
- mxs::WatchdogWorker defined with 'using'.
2018-11-21 13:31:49 +02:00
Johan Wikman
78829429ae MXS-2178 Add WD workaround to REST-API and maxadmin 2018-11-21 13:31:49 +02:00
Johan Wikman
be12cab16d MXS-2178: Provide workaround for watchdog notifications
The systemd watchdog mechanism requries notifications at
regular intervals. If a synchronous operation of some kind
is performed by a worker, then those notfications will not
be generated.

This change provides each worker with a secondary thread that
can be used for triggering those notifications when the worker
itself is busy doing other stuff. The effect is that there will
be an additional thread for each worker, but most of the time
that thread will be idle.

Sofar only the mechanism; in subsequent changes the mechanism
will be taken into use.
2018-11-21 13:31:49 +02:00