6183 Commits

Author SHA1 Message Date
Markus Mäkelä
f44d305a46
MXS-1949: Fix user injection warning
If a service has no active servers and users are injected, a warning would
be logged. This is a misleading warning if the service has no servers and
should only be logged if the failure to load any users is an unexpected
situation.
2018-07-05 12:49:46 +03:00
Markus Mäkelä
33fa9b26fe
Make version counter in mlist_t volatile
The log manager is the only one that uses the mlist_t versioned list. The
counter that keeps track of the version number was not modified using
atomic operations meaning that the compiler is free to optimize away parts
of the lock-free versioning mechanism that uses it.

To prevent this optimization, the variable is declared volatile. A rewrite
is direly needed but it cannot be done in 2.2.
2018-07-05 12:47:28 +03:00
Markus Mäkelä
7954de0da6
Always log commit ID
There's no good reason to not include the commit ID in release build
startup messages.
2018-07-05 12:01:38 +03:00
Markus Mäkelä
3f9a204116
Log unknown users and wrong passwords separately
If authentication fails due to a wrong password, a different error message
is logged. This should help resolve problems with user management.
2018-07-04 13:51:09 +03:00
Markus Mäkelä
79acbae4e5
Fix cache test build failure
The change in defaults caused the test to fail.
2018-07-04 13:51:09 +03:00
Markus Mäkelä
fb1c28c702
MXS-1948: Do round-robin worker assignment
Due to the skewed accept distribution without SO_REUSEPORT, we use
round-robin assignment of workers for new client connections. This
provides better performance as work is more likely to be evenly
distributed across all threads.

Using a least-busy-worker algorithm would provide a more stable result but
this is not trivially simple to implement. For this reason, the
round-robin based approach was chosen for 2.2.
2018-07-03 12:49:59 +03:00
Markus Mäkelä
e455e7f15d
MXS-1953: Always initialize the GWBUF spinlock
The spinlock in the buffer is used but it was not always initialized. Also
added missing initialization of the SERVER pointer.
2018-07-03 11:32:36 +03:00
Markus Mäkelä
013dfa79aa
Quote whitespace-only default values
Parameters that accept whitespace-only values need to have their default
values quoted if they contain only whitespace characters. In 2.2 the
qlafilter is the only module that did not do this.
2018-07-03 03:09:19 +03:00
Markus Mäkelä
ceb1c0f2a4
MXS-1950: Add missing error messages
When a valid target was not found, no error message was logged by the
router. This would cause the "Routing the query failed. Session will be
closed." message to be logged with no explanation as to why the routing
failed.

In addition to the above-mentioned case, no message would be logged if the
target for a COM_STMT_FETCH was not in use.
2018-07-03 02:08:25 +03:00
Markus Mäkelä
ed068f4d93
Expand authentication failure log message
If the authentication failure was due to a missing database, this extra
information can be logged. This will help cases where users are using
databases that do not exist.
2018-07-03 02:08:24 +03:00
Johan Wikman
b0902402b6 MXS-1940 Turn cache filter non-experimental
Also change the following defaults:

- "selects": Was "verify_cacheable", is now "assume_cacheable"
- "cached_data": Was "shared", is now "thread_specific"
2018-07-02 08:44:39 +03:00
Markus Mäkelä
f49c31625d
Use derived version of write for session commands
Prepared statements via readwritesplit need to have their IDs mapped from
the internal representation to the backend specific one. The RWBackend
class does this in its write method but the fix in commit
e561c3995c7396cf3749ccdf6a3357d7dd32c856 caused this to be bypassed and
the base version was always used.
2018-06-27 08:49:54 +03:00
Markus Mäkelä
f97f422379
Don't use closed backends
Only use backends that are still in use. The COM_STMT_EXECUTE and
COM_STMT_FETCH relationship caused unused backends to be used.
2018-06-27 08:49:21 +03:00
Markus Mäkelä
6183fab79b
MXS-1938: Log query for inconsistent replies
If a session command produces a different result on the slave than it did
on the master, a warning is logged. This warning now also logs the query
that was being executed to make investigation of the problem easier.
2018-06-25 08:44:13 +03:00
Markus Mäkelä
e561c3995c
Use correct write in Backend::execute_session_command
Backend::execute_session_command would use the overridden write method
instead of the Backend::write method that it intended to use. This caused
session commands that did not expect a response to be in a state that
expected a result.

Also fixed RWBackend::write pass the response_type value to
Backend::write.
2018-06-22 10:37:11 +03:00
Markus Mäkelä
0f61c4b6a4
MXS-872: Also check that mysql.user.default_role exists
The column is used so it should be checked that it exists. Also
altered the SQL to use statements that do not return resultsets.
2018-06-21 14:00:29 +03:00
Johan Wikman
45bda0f72e MXS-1936 Make qc_mysqlembedded compatible with qc_sqlite
qc_mysqlembedded must also be updated to handle the new type
QUERY_TYPE_DEALLOC_PREPARE. Some adjustements were also needed
elsewhere.
2018-06-21 12:51:47 +03:00
Markus Mäkelä
9e4b86ff0a
MXS-1935: Accent NULL from qc_get_preparable_stmt in readwritesplit
If the prepared statement cannot be extracted from the query, treat it as
a query with an unknown type.
2018-06-21 10:04:34 +03:00
Markus Mäkelä
14e03613a0
MXS-872: Use the new query only when privileges are OK
If the service user does not have adequate grants to the mysql tables, the
legacy query is used. This prevents an upgrade failure when the user was
lacking the new privileges.
2018-06-20 14:41:56 +03:00
Markus Mäkelä
28ae1bf24e
MXS-1932: Ignore hidden files in maxscale.cnf.d
All files that are hidden (i.e. start with a period) are now ignored by
the configuration file processing.
2018-06-20 14:41:55 +03:00
Johan Wikman
5d4b3bc419 MXS-1887 Prevent gwbuf_copy_data() performance hit
The cache filter walks through the resultset in order to detect
when the resultset ends. That is, it reads each packet header as
they arrive.

In case the resultset is large, the cache will have to read several
packet headers. That it does using gwbuf_copy_data(). However, as that
was done using the first received GWBUF as the starting point, it meant
that in gwbuf_copy_data() the buffer chain was walked over and over
and over again, with a significant performance hit as the result.

Now we separetely store the last buffer received, and the the starting
offset of it. That way there will be no buffer chain walking.

As this is a common problem, GWBUF could cache the offset of the tail,
thus removing the performance penalty if you read from an offset that
happens to be in the tail. However, it's better to do that as a part
of a general overhaul of GWBUF.
2018-06-20 12:45:22 +03:00
Markus Mäkelä
980caa5be5
MXS-1926: Ignore server shutdown errors
If the server sends a server shutdown error, it is safe for readwritesplit
to ignore it. When the TCP connection is closed, the router error handling
will discard the connection, optionally replacing it.
2018-06-20 00:34:16 +03:00
Markus Mäkelä
b018781764
MXS-872: Add support for roles
The users query for the MySQLAuth now handles users with default roles.
2018-06-19 12:52:00 +03:00
Markus Mäkelä
8eaa265168
MXS-1931: Remove use of gw_MySQL_get_next_packet
The function implemented redundant functionality and replacement with
modutil_get_next_MySQL_packet was planned.

When faced with a packet header spread over multiple buffers, the packet
length calculation would read past the buffer end. This is fixed by taking
modutil_get_next_MySQL_packet into use.

Identical behavior to the old function is achieved by calling
gwbuf_make_contiguous for each packet to store them in a contiguous area
of memory. This should be either removed and only done when
RCAP_TYPE_CONTIGUOUS_INPUT is requested or be made an innate feature of
statement based routing.
2018-06-18 20:42:23 +03:00
Markus Mäkelä
2ad8b77f11
Fix current command tracking in MariaDBClient
The debug assertion introduced by commit 3d1c2b421a fails when a
COM_CHANGE_USER was executed. This was caused by the fact that the
authentication data was being interpreted as a command when it should've
been ignored.

Added a debug assertion into the reauthentication code to make sure the
current command remains the same.
2018-06-18 11:32:28 +03:00
Markus Mäkelä
ca155fbfe9
Merge branch '2.1' into 2.2 2018-06-18 11:32:13 +03:00
Markus Mäkelä
d923042115
MXS-1930: Fix server version checks
The server versions now checks for 10.3 when deciding whether to send new
capabilities.
2018-06-18 10:55:39 +03:00
Esa Korhonen
09df017528 MXS-1886 Better auto-rejoin error description and tolerance
Auto-rejoin now explains more accurately if a server cannot be joined due
to conflicting gtid.

Also, auto-rejoin is no longer disabled if a join fails. Usually the fail
is due to the server not replying fast enough with query completion. The
query is often completed anyways. This can lead to some log spam.
2018-06-15 13:11:10 +03:00
Esa Korhonen
9e68d8ec3d MXS-1886 Auto-failover error tolerance
Auto-failover is no longer considered to have failed if the preconditions
are not met. An error message with the failed checks is printed once, but
the checks are repeated every loop as long as the master is down.
2018-06-15 12:52:03 +03:00
Markus Mäkelä
a983df5a7e
Fix testlogthrottling compilation failure
The ifstream constructor for some reason doesn't understand strings.
2018-06-15 11:45:40 +03:00
Markus Mäkelä
18f51eba79
Disable SQLite journal
The SQLite journal is not needed since the databases are created in-memory
and are thread-specific.
2018-06-15 11:16:27 +03:00
Markus Mäkelä
4cc4deeaf1
MXS-1843: Test log throtting in a unique directory
This rules out external influence as a reason for the test failure.
2018-06-15 10:07:49 +03:00
Markus Mäkelä
856d513040
MXS-1924: Enable WAL mode for sqlite
The mysqlauth SQLite database is now opened in WAL mode if possible. This
should prevent lockups of the database when the list of users is updated.

Also moved the starting of the SQLite transaction one level up to also
include the delete part in it. This should further reduce the effects of
updating users.
2018-06-15 10:01:28 +03:00
Markus Mäkelä
3d1c2b421a
MXS-1921: Explain why session was closed
When a client connection is closed by MaxScale before the client initiates
a controlled closing of the connection, an error message is sent. This
error message now also explains why the connection was closed to make
problem resolution easier.
2018-06-14 13:48:07 +03:00
Markus Mäkelä
315738f279
Merge branch '2.1' into 2.2 2018-06-13 23:15:11 +03:00
Markus Mäkelä
53177c30de
Fix runtime listener creation
The number of arguments to createListener was incremented but the maximum
count was not. Also fixed the parameter types for createListener and
alterServer.
2018-06-13 23:13:16 +03:00
Markus Mäkelä
143882ddce
Merge branch '2.1' into 2.2 2018-06-13 21:04:49 +03:00
Markus Mäkelä
1ea7c65861
Fix runtime alteration of servers
The server runtime alteration was broken by commit
c850336199c3c19508a3d280fb7000291d66b80c when it increased the maximum
argument count of the `alter server` command to 14.
2018-06-13 14:29:28 +03:00
Markus Mäkelä
1475b22eac
Upgrade REST-API npm packages
Upgraded packages to more recent versions.
2018-06-13 10:07:37 +03:00
Markus Mäkelä
e99d9826ad
Fix route_by_statement return value
The return value of route_by_statement was not initialized and not set if
a COM_CHANGE_USER was processed.
2018-06-12 23:55:30 +03:00
Markus Mäkelä
24870e278c
MXS-1913: Check session before invoking dcb_foreach callback
If the session is the dummy session, the callback should not be called.
2018-06-12 23:55:30 +03:00
dapeng huang
cd136b11a7 MXS-1891: dealloc named prepare should route to all (#174)
* dealloc named prepare route to all

* add newline

* erase from ps manager too

* little refactor
2018-06-12 10:45:11 +03:00
Markus Mäkelä
1a24f0a956
Merge branch '2.1' into 2.2 2018-06-11 10:36:57 +03:00
Markus Mäkelä
1e1734f42e
MXS-1910: Only require ssl_ca_cert for servers
Servers in MaxScale can encrypt the connections without client keys and
certificates. As keys and certificates are no longer required, the CA
certificate must always be initialized.
2018-06-09 00:15:48 +03:00
Markus Mäkelä
a7dd2127d6
Merge branch '2.1' into 2.2 2018-06-08 11:21:35 +03:00
Markus Mäkelä
c850336199
MXS-1907: Allow ssl_verify_peer_certificate when creating listener
When a listener is created at runtime or SSL is being enabled for an
already created listener, the ssl_verify_peer_certificate parameter can
now be defined.
2018-06-08 10:11:43 +03:00
Markus Mäkelä
6ba423cf94
Dump statements on unexpected internal state
If a server responds when no response was expected, dump stored
statements. This should help deduce root causes of problems relating to
unexpected responses.
2018-06-08 07:45:18 +03:00
Marko
0dd7448586 MXS-1709 Fix memory leaks in unit tests 2018-06-06 22:59:52 +03:00
Marko
3c0f301674 MXS-1709 Fix to test_server 2018-06-06 22:36:10 +03:00
Marko
82a95bfe2d MXS-1709 Fix memory leaks causing test_server to fail 2018-06-06 22:36:10 +03:00