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 reconnection change makes the second test faulty in
mxs359_error_on_write. After unblocking the master, the session will
reconnect to the master and the query will succeed.
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.
The templated provides an unary predicate for (shared) pointers that
allows containers containing pointers to objects to be searched, not by
pointer comparisons but by comparisons of the values that they point
to. This allows std::find_if to be used with shared pointers in a similar
manner that std::find is used with non-pointer objects.
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.
As they are deprecated, they should not be mentioned in the examples. Also
moved the router_options documentation under a Legacy Configuration
heading.
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.
The Backend::dcb() method gives the raw pointer to the internal DCB. This
pointer is used by at least readwritesplit to map raw DCB pointers to
backends. To prevent stale pointers from being returned, m_dcb needs to be
set to NULL after it has been closed.
The `MYSQL_ROW row` variable was being overwritten by the extra query done
by the SST method detection code. Moving it into its own function prevents
this and makes the code significantly easier to comprehend.
Added a test case that reproduced the problem (MaxScale crashed) and
verifies that the patch fixes the problem.
The previous core check would pick up any file in /tmp/ that would start
with the `core` prefix. This included some npm generated files which are
created if MaxCtrl is built on the MaxScale machine.
Also, the QueryResult integer reading method now only reads non-negative integers
since the server rarely returns negative values. This frees negative values for
indicating parsing error(s).
Gtid-class was moved back to utility.hh/.cc because the QueryResult-class requires it.