2819 Commits

Author SHA1 Message Date
Markus Mäkelä
c643f9bc8d
Merge branch '2.3' into develop 2019-04-12 13:23:49 +03:00
Markus Mäkelä
ec890b33cd
Prevent checksum mismatch on second trx replay
If a transaction replay has to be executed twice due to a failure of the
original candidate master, the query queue could contain replayed
queries. The replayed queries would be placed into the queue if a new
connection needs to be created before the transaction replay can start.
2019-04-05 13:33:16 +03:00
Markus Mäkelä
6421af1bb4
Backport query queue changes to 2.3
Backported the changes that convert the query queue in readwritesplit into
a proper queue. This changes combines both
5e3198f8313b7bb33df386eb35986bfae1db94a3 and
6042a53cb31046b1100743723567906c5d8208e2 into one commit.
2019-04-05 13:33:16 +03:00
Markus Mäkelä
daf5f52c64
Pass raw password to users_auth
By passing the raw password deeper into the authentication code, it can be
used to verify the user can access some systems. Right now, this is not
required by the simple salted password comparison done in MaxScale.
2019-04-05 00:42:00 +03:00
Markus Mäkelä
2aa3515fc8
Merge commit '09cb4a885f88d30b5108d215dcdaa5163229a230' into develop 2019-04-04 14:34:17 +03:00
Markus Mäkelä
a217dde1f0
MXS-2419: Queue queries executed during trx replay
By storing the queries in the query queue and routing it once the
transaction replay is done, we prevent two problems:

* Multiple transaction replays would overwrite the m_interrupted_query
  buffer that was used to store any queries executed during the
  transaction replay.

* Incorrect ordering of queries when the query queue is not empty and a
  new query is executed during transaction replay.
2019-04-03 12:57:05 +03:00
Markus Mäkelä
2dfd7d35ac
MXS-2418: Crash on trx replay when log_info is enabled
If the session starts with no master but later one becomes available, when
a transaction is started the code would unconditionally use the master's
name in a log message.
2019-04-03 12:57:05 +03:00
Markus Mäkelä
5242cd5ebf
Readwritesplit: Graceful maintenance mode
By allowing transactions to the master to end even if the server is in
maintenance mode makes it possible to terminate connections at a known
point. This helps prevent interrupted transactions which can help reduce
errors that are visible to the clients.
2019-04-02 14:21:54 +03:00
Esa Korhonen
d89f0c062b MXS-2271 Change Monitor->m_name to std::string
Also, monitor address is no longer printed.
2019-04-02 13:08:38 +03:00
Esa Korhonen
841bdf4d0f Merge branch '2.3' into develop 2019-03-28 15:33:09 +02:00
Markus Mäkelä
116efb2409
MXS-2379: Fix maxinfo HTTP interface
Added the missing HTTP request handlers and a new JSON conversion
function.
2019-03-28 14:03:56 +02:00
Markus Mäkelä
6bc2c54081
Merge commit 'a78f0fbe2537542dc7f3f0dd8b19b93ac8d9d7f8' into develop 2019-03-28 13:53:40 +02:00
Markus Mäkelä
18cd890474
Fix binlogrouter slave heartbeat task addition
The task was added multiple times when only one task is needed.
2019-03-28 13:21:24 +02:00
Markus Mäkelä
5ee9b74770
Fix readwritesplit server selection
If a server with zero weight was chosen as the only candidate, it was
possible that the starting minimum value was smaller than the server
score. This would mean that a candidate wouldn't be chosen if the score
was too high. To preven this, the values are capped to a value smaller
than the initial minimum score.
2019-03-28 13:21:23 +02:00
Esa Korhonen
c4b82b7d83 MXS-2359 Route statements with database but no table dependence
Queries such as SHOW TABLES FROM db1 are now routed to the backend with db1.
This gives the correct result as long as db1 is not sharded to multiple
backends.
2019-03-27 13:46:36 +02:00
Esa Korhonen
ee88180c54 MXS-2409 Check that prepared statement exists
If the PREPARE is malformed, the extracted statement is null.
2019-03-27 13:46:36 +02:00
Niclas Antti
d40e29d5f6 A little houskeeping.
Increasing counter sizes from int to long for averages.
Rename random functions to end with _co instead of _exclusive to
indicate range [close, open[, and to allow future suffixes oc, cc and oo.
2019-03-27 13:15:14 +02:00
Esa Korhonen
c6272594d6 MXS-2359 Remove special handling for SHOW TABLES
The code only handled the basic version of the command, returning incorrect
results if modifiers were used. The code is now removed, causing the command
to be routed to the backend of the current database. This will give correct
results as long as that backend contains all the tables of the database e.g.
no table sharding.
2019-03-27 10:30:29 +02:00
Markus Mäkelä
f8bc6b18fc
Only add tasks once in binlogrouter
Adding the same task twice isn't allowed. The API of the housekeeper tasks
might have to be changed in a way that makes it possible for the caller to
know whether a task has been added.
2019-03-26 13:44:04 +02:00
Markus Mäkelä
74eeb64fba
Don't close connections to servers being drained
The connections to servers being drained should not be closed like they
should be for servers in maintenance mode. The change in functionality
between 2.3 and develop caused the connections to be discarded if the
server was in either maintenance or drain mode.
2019-03-21 18:19:10 +02:00
Markus Mäkelä
c2fc80f122
Fix monitor creation
When the monitor was created, no parameters were passed to it.
2019-03-21 18:19:09 +02:00
Markus Mäkelä
9bc721afb6
Merge commit '11ee74bad327e7fb15e8388d20e7838b9e49cadf' into 2.3 2019-03-21 17:52:42 +02:00
Markus Mäkelä
11ee74bad3
Free the readwritesplit query queue
If the queue isn't empty when the session closes, the queue would leak.
2019-03-21 11:22:40 +02:00
Markus Mäkelä
6042a53cb3
Replace raw GWBUF pointers with mxs::Buffer
Now that the query queue is stored in an actual container, it is only
logical to use mxs::Buffer instead of GWBUF as the stored type.
2019-03-18 13:18:52 +02:00
Markus Mäkelä
5e3198f831
Replace the plain GWBUF query queue with std::deque
Using a std::deque to store the queries retains the exact state of the
object thus removing the need to parse the query again. It also removes
the need to split the queue into individual packets which makes the code
cleaner.
2019-03-18 13:18:52 +02:00
Markus Mäkelä
0001babd26
Clean up readwritesplit routing functions
Moved the more verbose parts of the routing code into subfunctions and
arranged it so that more relevant parts are closer to each other. Also
added the SQL statement that is being delayed to the message.
2019-03-18 13:18:52 +02:00
Markus Mäkelä
4bf9fa872c
MXS-2313: Use servers of same rank in readwritesplit
When a readwritesplit session has a connection to a master server, servers
of the same rank as the master are used. If no master connection is
available, the server with the highest rank among all connected servers is
used. If there are no open connections, the server with the best rank is
chosen and a connection to it is made.

Connections with different rank values than what is the current rank value
of the session will be discarded. This reduces the use of server with
different ranks when the master server of a session fails. Without the
active pruning of connections, slave connections to primary clusters
without masters would remain in use even after the primary master
fails. This guarantees full switchover to a secondary cluster if a master
change occurs.
2019-03-18 13:12:59 +02:00
Markus Mäkelä
109702ee72
Fix replication lag calculation in readwritesplit
The value used to represent the lack of a configured replication lag was
different than was used in other parts of MaxScale.
2019-03-18 13:12:59 +02:00
Markus Mäkelä
86520211b9
MXS-2313: Combine slave selection functions
The functions now do the candidate selection in one go. This removes the
unnecessary copying and split logic of server selection.
2019-03-18 13:12:59 +02:00
Markus Mäkelä
6befc7f7d4
MXS-2313: Fix candidate selection
If a master with a better rank and a slave with a worse rank were
available and master_accept_reads wasn't enabled, the slave would be
preferred over the master. The check for master_accept_reads was done
twice and also in the wrong place.
2019-03-18 13:12:59 +02:00
Markus Mäkelä
9b6b5270f1
MXS-2313: Use 64-bit integers to store rank
Although the default value is the maximum value of a signed 32-bit
integer, the value is stored as a 64-bit integer. The integer type
conversion functions return 64-bit values so storing it as one makes
sense.

Currently values higher than the default are allowed but the accepted
range of input should be restricted in the future.
2019-03-18 13:12:58 +02:00
Markus Mäkelä
aeca0f8a31
MXS-2313: Use rank in readconnroute
The rank is used for both root master selection as well as normal
candidate selection.
2019-03-18 13:12:58 +02:00
Markus Mäkelä
4f0538a041
MXS-2313: Use rank in readwritesplit
Readwritesplit now respects server ranks. When servers are selected for
either routing or connection creation, the servers are partitioned by
their rank into sets of servers. These sets of servers are never mixed so
the end result is that only servers of the same rank are considered for
candidacy.

The master selection is slightly different: the server with the best rank
that is capable of acting as a master is chosen. This means that a session
can have a master with a lower rank and slaves with higher ranks than the
master. In most cases this actually is the preferred behavior as the rank
is used to prioritize usage but not outright prevent it.
2019-03-18 13:12:58 +02:00
Markus Mäkelä
ba448cb12c
MXS-2313: Clean up readwritesplit connection creation
The connection creation is now internal to RWSplitSession. This makes the
code more readable by removing the need to pass parameters and allowing
easier reuse of existing functions. The various conditions require to
create connections are now also checked in only one place.
2019-03-18 13:12:58 +02:00
Markus Mäkelä
54a09e93df
Move thread_local sorting buffers inside functions
This way the use of the buffers is obvious and it removes the possibility
of two functions accidentally sharing the same buffer.
2019-03-18 13:10:23 +02:00
Markus Mäkelä
9e9cd0c596
MXS-2313: Pick best available master
Readwritesplit now picks the best available master if no open master
connection is available. This is required if the server rank is to be
taken into account when master selection is done.
2019-03-18 13:10:23 +02:00
Markus Mäkelä
4dda31ffe3
Merge branch '2.2' into 2.3 2019-03-16 09:30:56 +02:00
Markus Mäkelä
fd21bed5aa
Fix queued query handling
If a routing of a queued query caused it to be put back on the query
queue, the order in which the queue was reorganized was wrong. The first
query would get appended as the last query which caused the order to be
reversed.
2019-03-15 20:35:17 +02:00
Markus Mäkelä
995c890664
Fix uninitialized pointers in readwritesplit 2019-03-15 15:41:39 +02:00
Esa Korhonen
14b4fa632a MXS-2271 Move Monitor inside maxscale-namespace
Rearranged monitor.cc by namespace.
2019-03-15 12:57:35 +02:00
Markus Mäkelä
667a9f1c6f
Merge branch '2.3' into develop 2019-03-15 12:31:08 +02:00
Markus Mäkelä
09dc92973e
Discard connections as the last step
Th discarding of connections in maintenance mode must be done after any
results have been written to them. This prevents closing of the connection
before the actual result is returned.
2019-03-14 12:15:30 +02:00
Markus Mäkelä
e5edb5c78f
Fix reads into bad memory in readwritesplit
The candidate selection code used default values that would cause reads
past buffers. The code could also dereference the end iterator which
causes undefined behavior.
2019-03-14 12:15:30 +02:00
Markus Mäkelä
b537176248
Fix parsing of non-query packets
Packets that do not contain SQL should not be parsed.
2019-03-13 15:44:02 +02:00
Esa Korhonen
ac5ee1278c MXS-2271 Cleanup internal monitor header and its functions
Some functions still accessed the servers-array. Most functions are now
inside class. Removed unused defines.
2019-03-12 15:32:56 +02:00
Esa Korhonen
1858fe9127 MXS-2271 Monitor modifications always go through Monitor::configure()
Previously, runtime monitor modifications could directly alter monitor fields,
which could leave the text-form parameters and reality out-of-sync. Also,
the configure-function was not called for the entire monitor-object, only the
module-implementation.

Now, all modifications go through the overridden configure-function, which calls the
base-class function. As most configuration changes are given in text-form, this
removes the need for specific setters. The only exceptions are the server add/remove
operations, which must modify the text-form serverlist.
2019-03-12 10:19:45 +02:00
Markus Mäkelä
1c3a5bda83
Merge branch '2.3' into develop 2019-03-11 12:29:56 +02:00
Markus Mäkelä
710e5df27b
MXS-2365: Fix classification of queued queries
Queries in the query queue need to be explicitly parsed since they are
stored in a single buffer and thus share the query classification
information. In the next major version this should be changed into an
array of individual buffers instead of a shared buffer.
2019-03-08 14:45:18 +02:00
Markus Mäkelä
18a30f05c2
Connect to master on read if master_accept_reads is on
The master should be considered as a valid target when master_accept_reads
is enabled but a connection to it has not yet been created.
2019-03-08 08:20:44 +02:00
Markus Mäkelä
bfc874dea1
MXS-2350: Connect on session command with lazy_connect
If a session command is executed when lazy_connect is enabled and no
connections have been created, a connection must be made. This makes sure
that the session isn't closed and that the client receives a response.
2019-03-08 08:20:44 +02:00