8269 Commits

Author SHA1 Message Date
Markus Mäkelä
3813c728b1
Move listener parameter handling into Listener::create
The Listener::create method now takes a set of configuration parameters
from which it constructs a listener. This removes the duplicated code and
makes the behavior of listener creation similar to other objects in
MaxScale. It also allows the configuration parameters to be stored in the
listener object itself.
2019-05-10 09:21:52 +03:00
Johan Wikman
23a09a6294 MXS-2455 Use mxb::Buffer::iterator
Simplifies the code and as extra allocations etc. are only
made when info is enabled, and can thus be ignored.
2019-05-09 15:04:03 +03:00
Johan Wikman
381940ce8c Merge branch '2.3' into develop 2019-05-09 14:35:44 +03:00
Markus Mäkelä
567ad9b8b8
Fix galeramon regression
The comparisons were wrong: strcasecmp returns 0 for equal strings.
2019-05-09 12:30:29 +03:00
Markus Mäkelä
59f2145c00
Allocate blr heartbeat buffer on correct worker
The buffer was allocated on one worker and written on another.
2019-05-09 12:30:29 +03:00
Markus Mäkelä
788dc429f8
Do client callback on owning worker
The callback should've been done on the worker that owns the DCB instead
of the main worker.
2019-05-09 12:30:26 +03:00
Johan Wikman
b313c6d0e7 MXS-2474 Ignore attempts to re-register a housekeeper task
It is an error to register the same task multiple times, but
for a maintenance release it is simpler and less risky to simply
ignore an attempt (that BLR does) to do that.

Allowing a task to be registered anew causes behaviour akin
to a leak.
2019-05-09 10:58:35 +03:00
Esa Korhonen
e3b5ba9620 MXS-1973 Support reverse DNS for client hostnames in MaxCtrl
May slow maxscale down when used. Only supported for "list sessions",
"show sessions" and "show session <id>".
2019-05-08 15:04:44 +03:00
Markus Mäkelä
0e0342e657
Merge branch '2.3' into develop 2019-05-08 10:38:39 +03:00
Markus Mäkelä
a652b6bd5b
Add advance(int) to mxs::Buffer iterators
This makes iterating over packets in buffers faster while still
maintaining the requirements for forward iterators. Not using operator+=
makes it clear that this is not a random access iterator.
2019-05-08 10:33:27 +03:00
Markus Mäkelä
bad96e411a
Merge branch '2.3' into develop 2019-05-08 10:30:58 +03:00
Johan Wikman
c818b1208a MXS-2455 Recognize transaction rollbacks
All transaction rollback errors have an sql_state like "40XXX".
So, when an error reply is received we check for that and act
accordingly.
2019-05-08 10:00:50 +03:00
Markus Mäkelä
0638ea736e
Write slave heartbeat in correct thread
The writing should be done on the worker that owns the DCB.
2019-05-08 09:44:55 +03:00
Marko
446788f2ed MXS-1799 Add timestamps to retain_last_statements messages 2019-05-07 22:54:31 +03:00
Marko
3d66e68e95 MXS-2170 Start MaxScale normally if it gets the same PID as previous
MaxScale

Check is made to see if the found MaxScale PID is owned by the process
itself.
2019-05-07 22:23:46 +03:00
Esa Korhonen
4e6ffc0381 Clean up server config parameter handling
Removes helper classes which are no longer required.
2019-05-07 15:39:34 +03:00
Johan Wikman
d3a1f5c51f MXS-2463 Prefer range loops
Also consistently use 'kv' as in key-value as the element name
when the collection looped over is a map.
2019-05-07 10:36:21 +03:00
Johan Wikman
4cf29bea36 MXS-2463 Rename m_nodes to m_nodes_by_id
Makes it obvious it is a map.
2019-05-07 10:36:21 +03:00
Johan Wikman
3c9ad0e452 MXS-2463 Ignore persisted data if bootstraps have changed
If there have been any changes in the bootstrap servers specified
for the Clustrix monitor, then the persistent connection information
is not used.

Otherwise, if the bootstrap server is changed and inaccessible, we
may connect to another cluster than the intended one.
2019-05-07 10:36:21 +03:00
Johan Wikman
ff33453e1a MXS-2463 Prepare for another set of queries
Persisted information about dynamic nodes must be used only if
the bootrap information has not been changed, as otherwise we risk
using information that is not valid.
2019-05-07 10:36:21 +03:00
Markus Mäkelä
95fd61b8dc
Fix listener search functions
The functions that searched for listeners compared both sockets and
addresses in the same function. This made its use error prone and caused
false positives in some cases.
2019-05-06 19:55:31 +03:00
Markus Mäkelä
6b8ca35408
Format core source files
Formatted core .cc files according to current uncrustify configuration.
2019-05-06 16:05:50 +03:00
Markus Mäkelä
5ac24de6b0
Remove log_to_shm
The feature was removed in 2.3 and was ignored if configured.
2019-05-06 16:05:50 +03:00
Markus Mäkelä
20a7170024
Fix unit tests that use durations
The tests that used objects that expected a default value for a duration
failed due to missing parameters.
2019-05-06 15:38:43 +03:00
Johan Wikman
6f607e13de MXS-2446 Do not assume created server exists
"Once you eliminate the impossible, whatever remains, no matter
 how improbable, must be the truth." Arthur Conan Doyle

Since server objects are never destroyed, currently the only
explanation for the crash described in MXS-2446 is that a server
created at runtime could not, immediately after the creation, be
found using its name.
2019-05-06 12:13:29 +03:00
Johan Wikman
6baf970140 Fix test_dbfwfilter 2019-05-03 16:12:26 +03:00
Johan Wikman
9a10f64840 Fix test_cacheoptions 2019-05-03 16:09:14 +03:00
Johan Wikman
86b099b487 MXS-2468 When the URLs change, HTTP GET must be cancelled
If the nodes change while a multi HTTP GET is in process, the
corresponding delayed called must be cancelled. Otherwise we
eventually would end up attempting to update the state of the
nodes using the wrong result.
2019-05-03 15:00:00 +03:00
Johan Wikman
fb0745e3de Merge branch '2.3' into develop 2019-05-03 13:48:57 +03:00
Johan Wikman
a3cf1d22c0 MXS-2457 Streamline logging 2019-05-03 13:38:12 +03:00
Johan Wikman
279edce16e MXS-2457 Add treat_string_as_field to firewall
Necessary if the firewall should be able to block columns when
'ANSI_QUOTES' as enabled and " instead of backticks are used.

Without this, the following

    > set @@sql_mode='ANSI_QUOTES';
    > select "ssn" from person;

will not be blocked if the database firewall has been configured
to block the column ssn.
2019-05-03 13:38:12 +03:00
Johan Wikman
5833c39a8a MXS-2457 Disable query classifier cache in masking
As the canonicalization is also not aware of 'ANSI_QUOTES', the
cache must be disabled if the masking filter has
'treat_string_arg_as_field' enabled.
2019-05-03 13:38:12 +03:00
Johan Wikman
fe5160a714 MXS-2457 Add 'treat_string_arg_as_field' to DB Firewall 2019-05-03 13:38:12 +03:00
Johan Wikman
3a5a8b13b9 MXS-2457 Treat string args as fields
The masking filter will now consider all string arguments to
functions to be fields. This in order to prevent bypassing of
the masking with

    > set @@sql_mode='ANSI_QUOTES';
    > select concat("ssn") from masking;

This may lead to false positives, but no can do.
2019-05-03 13:38:12 +03:00
Johan Wikman
f09d46c8e6 MXS-2457 Allow string arguments to be treated as fields
Before this change, the masking could be bypassed simply by

    > set @@sql_mode='ANSI_QUOTES';
    > select concat("ssn") from person;

The reason is that as the query classifier is not aware of whether
'ANSI_QUOTES' is on or not, it will not know that what above appears
to be the string "ssn", actually is the field name `ssn`. Consequently,
the select will not be blocked and the result returned in cleartext.

It's now possible to instruct the query classifier to report all string
arguments of functions as fields, which will prevent the above. However,
it will also mean that there may be false positives.
2019-05-03 13:38:12 +03:00
Markus Mäkelä
20afbfca76
Merge branch '2.3' into develop 2019-05-02 20:24:04 +03:00
Markus Mäkelä
3dd9298b18
MXS-2456: Test transaction replay cap
Added a test that makes sure the transaction replay cap is respected. Also
improved the logging to show how many transaction replay attemps have been
done and to log if a replay is not done due to too many attempts.
2019-05-02 16:59:36 +03:00
Markus Mäkelä
26b2897280
MXS-2456: Cap transaction replay attempts
In most cases it is reasonable to stop attempting transaction replays
after a certain number of failed attempts. This prevents transactions from
being repeatedly replayed on the same server over and over again if, for
example, it keeps crashing.
2019-05-02 16:59:36 +03:00
Markus Mäkelä
bc654849e8
Fix duration JSON representation
Duration values converted to JSON are now again returned as integers. This
keeps the REST API backwards compatible until suffixed durations are no
longer supported at which point all duration values can be represented in
milliseconds.
2019-05-02 16:54:19 +03:00
Markus Mäkelä
0d61522586
Fix test_adminusers
The test did not remove old inet user password files.
2019-05-02 12:53:42 +03:00
Markus Mäkelä
0c5a45cb85
MXS-2414: Remove unused variable 2019-04-30 14:49:36 +03:00
Markus Mäkelä
59be841939
MXS-2414: Rename max_auth_failures to max_auth_errors_until_block 2019-04-30 14:49:36 +03:00
Markus Mäkelä
6caa8e55b0
MXS-2414: Send error when host is blocked
If a connection attempt is not accepted due to the host being blocked, the
protocol can now return an error message that is sent to the client. Only
mariadb_client implements this as it is the only one who calls the auth
failure methods in the first place.
2019-04-30 14:49:35 +03:00
Markus Mäkelä
db0e491ace
MXS-2414: Add max_auth_failures parameter
The parameter controls how many authentication failures are allowed until
the host is blocked. The default is 10 failures per thread.
2019-04-30 14:49:35 +03:00
Markus Mäkelä
cf86b0cb7e
MXS-2414: Prototype connection attempt throttling
The RateLimit class stores authentication failure data mapped by the
client IP addresses. The authentication failures are limited
per thread. The limits are still hard-coded and at least the number of
failures should be made configurable.

The simplest, most maintainable and acceptably efficient implementation
for DDoS protection is a thread-local unordered_map. The unwanted
side-effect of "scaling" of the number of allowed authentication failures
is unlikely to be problematic in most use-cases.

As the blocking of a host is only temporary, the behavior differs from the
one in the MariaDB server. This allows the number of failures to be set to
a much lower value negating some of the problems caused by the relatively
simple implementation.
2019-04-30 14:49:35 +03:00
Johan Wikman
d1ab4fcb89 MXS-2329 Fix missing duration type 2019-04-30 14:31:47 +03:00
Esa Korhonen
82b4338eca Remove MonitorManager calls from Monitor functions
Also adds admin thread checks to MonitorManager functions and combines
anonymous namespaces.
2019-04-30 13:45:48 +03:00
Esa Korhonen
c4b27cdefc Store server->monitor relation in a map
Removes the need to iterate through monitor serverlists. Also adds asserts to verify
that monitor modifications are done only from an admin thread.
2019-04-30 13:45:48 +03:00
Johan Wikman
2115322737 MXS-2329 Change warning into info
Currently it's too laborious to use duration suffixes when saving
generated configs and also to handle suffixes when changes are made
dynamically using maxctrl.

It will be trivial to do that when the new configuration mechanism
has been taken into use everywhere. That will not happen before
MaxScale 2.5.

So, in MaxScale 2.4 duration suffixes will be accepted in manually
created configuration files, but no warning will be logged if a
suffix is not used.
2019-04-30 13:02:53 +03:00
Johan Wikman
3d420dee6f MXS-2329 Use durations in MariaDB monitor 2019-04-30 13:02:53 +03:00