456 Commits

Author SHA1 Message Date
Esa Korhonen
a3bb61486d Move server_set_status and server_clear_status to monitor
The operation goes through monitor code so should be in the according file.
2019-05-10 14:37:35 +03:00
Markus Mäkelä
6625c1296b
Format authenticator and protocol modules 2019-05-10 10:31:12 +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ä
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ä
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
Markus Mäkelä
4186f39616
Merge branch '2.3' into develop 2019-04-23 12:11:09 +03:00
Markus Mäkelä
24fc82e160
Move large query processing inside RWBackend
The knowledge of which function to call can be internal to RWBackend. This
make the use of the class easier as one can simply write to the backend.
2019-04-18 13:58:34 +03:00
Markus Mäkelä
03dc969cf2
Fix use-after-free in LocalClient
If the DCB was closed before the handshake for the LocalCliet connection
was received, the gw_decode_mysql_server_handshake would use the closed
DCB to log the connection ID. Clearing out the pointer prevents it.
2019-04-17 16:33:27 +03:00
Markus Mäkelä
d3bfe0a712
Fix handling of large result packets
The RWBackend didn't know to skip the tail end of large packets.
2019-04-17 11:16:16 +03:00
Markus Mäkelä
70450ce881
MXS-2349: Add support for UNIX domain sockets
Added core functionality for UNIX domain sockets in servers. Currently the
address parameter accepts them both but a separate `socket` parameter is
needed.
2019-04-16 11:52:37 +03:00
Markus Mäkelä
21b4cc3944
Merge branch '2.3' into develop 2019-04-15 15:13:50 +03:00
Markus Mäkelä
bd54efbb3f
Fix skip_encoded_int
A single byte integer wasn't skipped.
2019-04-15 12:18:30 +03:00
Markus Mäkelä
f6bd9fefa4
Move assertion after error message
Logging the internal state before the assertion makes it easier to figure
out why the assertion failed in the first place.
2019-04-15 12:07:48 +03:00
Markus Mäkelä
b3399dccc4
Remove useless templates from RWBackend functions
There's no need for templates as the code is only used with one
type. Changed the code to use std::advance as that might avoid a copy of
the iterator.
2019-04-12 16:31:43 +03:00
Markus Mäkelä
c643f9bc8d
Merge branch '2.3' into develop 2019-04-12 13:23:49 +03:00
Markus Mäkelä
d2ecaa83a6
Move result start handling into separate function
The largest part of the code deals with the start of a response. Moving
this into a subfunction makes the function clearer as the switch statement
inside a switch statement is removed.
2019-04-12 09:18:07 +03:00
Markus Mäkelä
746bd53668
Simplify RWBackend result handling
By processing the packets one at a time, the reply state is updated
correctly regardless of how many packets are received. This removes the
need for the clunky code that used modutil_count_signal_packets to detect
the end of the result set.
2019-04-12 09:18:05 +03:00
Markus Mäkelä
e6526dd9ea
Add extra info logging to readwritesplit
Added logging into RWBackend reply state processing code to know more.
2019-04-12 09:17:48 +03:00
Markus Mäkelä
05515cca16
MXS-2259: Limit size of client reads
Given the assumption that queries are rarely 16MB long and that
realistically the only time that happens is during a large dump of data,
we can limit the size of a single read to at most one MariaDB/MySQL packet
at a time. This change allows the network throttling to engage a lot
sooner and reduces the maximum overshoot of throtting to 16MB.
2019-04-05 22:48:16 +03:00
Markus Mäkelä
9722c0887a
Log connection ID when reading server handshake
By logging the connection ID for each created connection, failures can be
traced back from the backend server all the way up to the client
application.
2019-04-05 13:33:16 +03:00
Markus Mäkelä
db97c3343d
MXS-1951: Move worker selection into Listener
The worker to which the client DCB is assigned to is now chosen by the
Listener. This makes the protocol code simpler which is always a good
thing.
2019-03-28 16:34:12 +02:00
Esa Korhonen
2f634264dc Merge branch '2.3' into develop 2019-03-22 13:39:52 +02:00
Esa Korhonen
fadbdc7514 Merge branch '2.2' into 2.3 2019-03-22 12:11:24 +02:00
Esa Korhonen
9236ace077 MXS-2355 If client is using the wrong authenticator, attempt a switch
Some SQL clients may default to a different authentication plugin than
"mysql_native_password". Since this is the only one supported by MySQL-
authenticator, the client is instructed to swap its plugin.
2019-03-21 17:07:09 +02:00
Johan Wikman
2ba7e63e7e Merge branch '2.3' into develop 2019-03-21 09:26:06 +02:00
Markus Mäkelä
0b77c3f05f
MXS-2324: Prevent stack overflow with large results
If a result consists of only OK packets, they would be processed
recursively which most of the time leads to a stack overflow. This can be
prevented by consuming all OK packets in the result in one go.
2019-03-20 10:29:03 +02:00
Markus Mäkelä
1c3a5bda83
Merge branch '2.3' into develop 2019-03-11 12:29:56 +02:00
Markus Mäkelä
5c5c6630bf
Fix retain_last_statements
If multiple statements were stored in a single buffer only one of them
would get registered.
2019-03-08 14:45:18 +02:00
Markus Mäkelä
7db87784ac
Deliver hangups only to valid DCBs
If a DCB was closed and a hangup event was sent to it via
dcb_hangup_foreach shortly after it was closed, the DCB would still
receive it even if it was closed. To prevent this, events must only be
delivered to DCBs if they haven't been closed.
2019-03-08 12:10:30 +02:00
Markus Mäkelä
95317725ce
Merge branch '2.3' into develop 2019-03-07 16:21:03 +02:00
Markus Mäkelä
5b43940559
Track session state only when required
The protocol should not track the session state as the parsing is quite
expensive with the current code. This change is a workaround that enables
the parsing only when required. A proper way to handle this would be to do
all the response processing in one place thus avoiding the duplication of
work.
2019-03-07 15:59:26 +02:00
Markus Mäkelä
9572ff84ea
Merge branch '2.3' into develop 2019-03-05 10:37:56 +02:00
Markus Mäkelä
7fb2ae571b
Improve blocked host error message
The error now explains how the problem can be mitigated by increasing
max_connect_errors on the backend server.
2019-03-04 08:53:12 +02:00
Markus Mäkelä
661f1dd4e4
Merge branch '2.3' into develop 2019-02-11 13:14:52 +02:00
Markus Mäkelä
d04fc6c4b9
Merge branch '2.2' into 2.3 2019-02-08 16:14:58 +02:00
Markus Mäkelä
46484b4e11
MXS-2311: Write queued packet one at a time
If an ignorable packet was followed by more than one queued packets, they
would all get routed in the same batch. This would cause unexpected
replies from the server if multiple ignorable packets were queued up.
2019-02-08 14:18:41 +02:00
Markus Mäkelä
42b5c39f43
Merge branch '2.3' into develop 2019-02-07 10:50:27 +02:00
Markus Mäkelä
08a05d3ab9
Fix use of uninitialized variables
Building with optimization in debug mode revealed code that could in
theory result in undefined behavior.
2019-02-06 14:22:24 +02:00
Esa Korhonen
7fb80c530b Merge branch '2.3' into develop 2019-01-21 14:05:16 +02:00
Esa Korhonen
3b55893a20 Combine maxscale/buffer.h with maxscale/buffer.hh 2019-01-17 12:37:40 +02:00
Markus Mäkelä
ebbb8a771c
Merge branch '2.3' into develop 2019-01-17 10:55:27 +02:00
Markus Mäkelä
a469ef83b6
MXS-2217: Pick DCB owner before adding to epoll
There is a race condition between the addition of the DCB into epoll and
the execution of the event that initiates the protocol pointer for the DCB
and sends the handshake to the client. If a hangup event would occur
before the handshake would be sent, it would be possible that the DCB
would get freed before the code that sends the handshake is executed.

By picking the worker who owns the DCB before the DCB is placed into the
owner's epoll instance, we make sure no events arrive on the DCB while the
control is transferred from the accepting worker to the owning
worker.
2019-01-17 10:35:49 +02:00
Markus Mäkelä
a3fa2f8111
Merge branch '2.3' into develop 2019-01-16 16:31:14 +02:00
Markus Mäkelä
021d48f94c
Log low-level reason and idle time on master failure
If the connection to the master is lost, knowing what type of an error
caused the call to handleError helps deduce what was the real reason for
it. Logging the idle time of the connection helps detect when the
wait_timeout of a connection is exceeded.
2019-01-16 09:43:49 +02:00
Esa Korhonen
d4674faa7d Convert maxscale/query_classifier.h to .hh
The header was not merged with queryclassifier.hh since the latter
does not include the former.
2019-01-15 18:18:39 +02:00
Esa Korhonen
45bfbbdd9e Convert maxscale/protocol.h to .hh 2019-01-15 17:26:26 +02:00
Esa Korhonen
b0663f0b29 Convert maxscale/ssl.h to .hh 2019-01-15 17:12:32 +02:00
Esa Korhonen
684ec3288b Rename and cleanup authenticator.h 2019-01-14 15:07:33 +02:00
Esa Korhonen
1c647f3753 MXS-2220 Move most remaining functions inside class
Most of the ones still remaining outside are special cases.
Also, removed locking from status manipulation functions as it
has not been required for quite some time.
2019-01-08 15:15:34 +02:00