A readwritesplit session must have a client DCB and the DCB must
have data, otherwise the system is seriously broken. So no point
in checking for that and logging an error. Situations like that
might have been possible in the olden days when a session could
be manipulated by multiple threads at the same time.
A member variable and local variable had the same names which caused the
member variable to not be used. With the change in the member variable,
this went unnoticed.
The use of `router_options=master,slave` was not working as expected. This
was mostly caused by the master bit checks using a bitwise AND instead of
comparing equality. In addition to this, the master would not be
considered a valid candidate if both slaves and masters were available.
The MASTER_GTID_WAIT "prefix" should only be added if it fits into one
packet. This is not a complete solution as it prevents queries larger than
16MB from benefiting from the consistent reads.
Keeping track of the closed state of the session inside the router session
itself is not needed as the MaxScale core should already do that.
The skygw_chk_t variables are rather meaningless and are obsoleted by
Valgrind/ASAN.
Most of the funtionality is now a member function of either the RWSplit or
RWSplitSession class. This removes the need to pass the router and session
parameters to all functions.
The warning that tells the user that the session command history has been
exceeded is now only logged once. This is to prevent the message from
being repeatedly logged when the default value is not large enough.
Also fixed the session_limits test to use distinct session commands. This
way the session command history compaction is not in effect and the test
again tests the correct thing.
It is possible, and perfectly OK, for the new master to be in use at the
same time the old master is. This is the case if one of the slaves is
promoted as the master.
The get_backend_from_dcb function needs to check that the backend is in
use before comparing the pointer. This prevents stale pointers from being
used and is logically more sound than relying on raw DCB matches.
The code that logs the master failure error was not working correctly
after the changes done for MXS-359 and MXS-1503. Updated the logic and
converted impossible cases into debug assertions.
The master_failure_mode=error_on_write mode was broken due to a faulty
assumption that all successfully routed queries would produce a
target. This is not the case when a write in error_on_write mode is
received.
Moved the RWBackend class implementation into its own file. Made some of
the command type functions a part of the <maxscale/protocol/mysql.h>
header to make it reusable.
Before the transaction migration is implemented, the connection must be
closed if a transaction is open and the connection to the master is
lost. Doing this retains the same transactionality as a direct connection
to the server would.
When a non-connected target is chosed as the target server and the session
command history is not empty, the query needs to be placed into the query
queue and routed only after the session commands have been executed.
The session command history is now compacted to contain only the first and
last execution of a session command. This should still allow most of the
more eccentric use-cases of user variables while keeping the session
command history smaller.
Added some convenience functions into the SessionCommand class to make the
pruning process easier.
Enabling the session command history but limiting it to a history of 50
commands allows reconnections for sessions that don't change the state too
often.
As pooled connections will exceed this limit quite fast, they are not able
to reconnect to servers once connections are lost. To solve this problem,
the session command history needs a compaction process that removes
redundant history.
The slave selection now again respects max_slave_connections. This means
that the amount of slave connections each session has will never grow
beyond the configured value.
The slave connections can now be recovered after a failure as long as the
session command history is enabled. In comparison to the old
functionality, the server now replaces the connection when a query is
received instead of reconnecting when the slave fails.
As a negative side effect of this change, the max_slave_connections is no
longer enforced after the connection is created. To fix this broken
functionality, the connected slaves need to be preferred over unconnected
ones. This will be added in a follow-up commit.
The `master_reconnection` parameter now controls both the reconnection of
the master server as well as the migration of the master server to another
server. Although these two cases appear to be different, the end result
from readwritesplit's point of view is the same and are thus controlled
with the same parameter.
The RWBackend class now resets its internal state when it is closed. This
allows readwritesplit to handle the case when a result was expected from
the master but the master died before the result was returned. The same
code should also handle slave connection failures mid-result, allowing
Backend reuse.
Added a test case that verifies the new functionality when combined with
`master_failure_mode=error_on_write`.
Moved session command execution into the Backend class itself as the
session commands are defined as a related part of it. This allows all
connections to execute session commands if some are available.
Removed explicit SERVER_REF usage in the readwritesplit connection
creation code and replaced it with SRWBackend. This allows the removal of
the get_root_master_backend function which duplicated the functionality in
get_root_master.
Disabled the reconnection in clientReply prior to moving the connection
creation code into routeQuery. This allows new connections to be made when
they are needed.