Commit Graph

2285 Commits

Author SHA1 Message Date
00ee271656 MXS-1625 Remove need for RWS session in log_transaction_status() 2018-04-05 13:54:37 +03:00
08987e3e85 MXS-1625 Remove need for RWS session in check_create_tmp_table 2018-04-05 13:42:39 +03:00
1133173a65 MXS-1625 Move tmp table management to QueryClassifier
Eventually only managed by QueryClassifier.
2018-04-05 13:38:55 +03:00
59d257579c MXS-1625 Move LOAD DATA sent statistics to QueryClassifier
Eventually the tracking will be internal to QueryClassifier.
2018-04-05 12:46:27 +03:00
340c132096 MXS-1625 Remove runtime checks for impossible errors
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.
2018-04-05 12:24:13 +03:00
8c0033ccb2 MXS-1625 Figure out multi statement state at startup
Whether or not multi statements are allowed is checked when
the QueryClassifier instance is created.
2018-04-05 10:16:23 +03:00
25386c4381 MXS-1625 Use PSManager of QueryClassifier 2018-04-05 10:16:23 +03:00
befc34dea7 Fix RWSplitSession::route_stored_query
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.
2018-04-04 20:54:46 +03:00
a2fcecd98f MXS-1743: Fix usage of both master and slave types
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.
2018-04-04 19:43:46 +03:00
8596fea62a MXS-1625 Fix rebase breakage 2018-04-04 15:26:29 +03:00
c08120846c MXS-1625 large_query flag moved from RWS session to query classifier 2018-04-04 15:20:38 +03:00
bc22790e1b MXS-1625 Move tmp table state variable to mxs::QueryClassifier 2018-04-04 15:18:51 +03:00
8220c31664 MXS-1625 Move load data state to QueryClassifier
Still managed from the outside, but eventually will be managed
entirelly by QueryClassifier.
2018-04-04 15:16:46 +03:00
563fa2c840 MXS-1625 Add QueryClassifier instance to RWSplitSession
The readwritesplit session now has a mxs::QueryClassifier instance
as member.
2018-04-04 15:13:51 +03:00
0771701d94 Rename readwritesplit member variables
Prefixed the variables with the `m_` prefix and changed some of them to be
more descriptive.
2018-04-04 14:59:56 +03:00
5e64695492 Move RWSplitSession methods into rwsplitsession.cc
Moved the RWSplitSession method implementations into the correct files.
2018-04-04 14:51:49 +03:00
87de1dc468 Only add MASTER_GTID_WAIT if it fits into one packet
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.
2018-04-04 14:47:29 +03:00
5a846063c1 Fix assignment of varible to itself
Caused by refactoring.
2018-04-04 14:33:00 +03:00
a762b76cbf MXS-1506: Remove redundant variables
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.
2018-04-04 08:51:26 +03:00
15f15be49d Move most readwritesplit functions into classes
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.
2018-04-03 23:22:29 +03:00
ce500d782a MXS-1502: Improve max_sescmd_history warning message
The message now suggests what the user should do.
2018-04-03 16:28:09 +03:00
7d7cef7dcd Use router template in readwritesplit
Take the router template into use in readwritesplit.
2018-04-03 16:27:19 +03:00
6a481ca21e MXS-1625 Use QueryClassifier in RouteInfo
Eventually the RWS session will contain a QueryClassifier
object as a member variable.
2018-04-03 16:02:18 +03:00
36b10d3f05 MXS-1502: Log session command warning only once
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.
2018-04-03 13:32:10 +03:00
07821970ff MXS-1503: Remove false debug assertion
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.
2018-04-03 13:32:10 +03:00
caa5fe89bb MXS-1503: Make sure backend is in use before using it
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.
2018-04-03 13:32:10 +03:00
be0ab82283 MXS-1503: Fix master failure logging logic
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.
2018-04-03 13:32:10 +03:00
319122e621 MXS-1502: Add have_session_commands helper function
The function conveys the meaning of the call better than using
session_command_count to check whether there are session commands to be
executed.
2018-04-03 13:32:10 +03:00
7d4f37d25b MXS-1503: Fix read-only mode regression
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.
2018-04-03 13:32:09 +03:00
a15d36b2f0 MXS-1503: Take EqualPointees<T> into use
Take the template into use in readwritesplit.
2018-04-03 13:31:53 +03:00
14e399dd68 Move RWSplitSession into rwsplitsession.cc
Moved the class method definitions into the correct file.
2018-04-03 13:30:55 +03:00
d5643bc14d Create RWBackends from servers
Added a helper function that creates a list of servers to use. This should
remove some of the duplicate code in the routers.
2018-04-03 13:30:55 +03:00
6ef9e1fd9a Move RWBackend into a separate file
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.
2018-04-03 13:30:55 +03:00
8206e1f46d Move RWBackend::reply_is_complete into rwsplitsession.cc
The function is now defined in the correct file. Removed the debug output
as it can be logged inside RWBackend::set_reply_state.
2018-04-03 13:30:54 +03:00
8222bdbc20 Move reply_is_complete into RWBackend
Moved the reply state checking inside the RWBackend class to make it
possibly reusable in other parts of MaxScale. Also removed a redundant
function.
2018-04-03 13:30:54 +03:00
3857912c61 MXS-1503: Abort connection when inside transaction
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.
2018-04-03 13:30:54 +03:00
7f0745e552 MXS-1503: Queue command if executing a session command
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.
2018-04-03 13:30:53 +03:00
e57ac4b0a3 MXS-1502: Prune session commands
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.
2018-04-03 13:30:53 +03:00
ce853d3f7f MXS-1503: Enable limited session command history
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.
2018-04-03 13:30:53 +03:00
7e4665b03b MXS-1503: Respect max_slave_connections
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.
2018-04-03 13:30:52 +03:00
4cf9bec10b MXS-1503: Restore slave reconnection
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.
2018-04-03 13:30:52 +03:00
3d63d18bdd MXS-1503: Split get_target_backend into smaller pieces
Split the code into separate functions. This should make it easier to
comprehend.
2018-04-03 13:30:52 +03:00
9c7578272c MXS-1503: Refactor slave selection
Refactored and cleaned up the slave selection in preparation of
reconnection code unification.
2018-04-03 13:30:52 +03:00
876187b340 MXS-1503: Enable master reconnection
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`.
2018-04-03 13:30:51 +03:00
481db8acbc MXS-359: Rename parameter to master_reconnection
Changing the parameter name to `master_reconnection` allows similar
reconnection functionality to be combined under one parameter.
2018-04-03 13:30:51 +03:00
3f803ab3e8 MXS-1503: Don't use empty smart pointers
The check for the existence of a valid pointer is now done in the correct
place.
2018-04-03 13:30:51 +03:00
be2186c8f1 MXS-1503: Remove redundant code
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.
2018-04-03 13:30:51 +03:00
a1b5fcd4ff MXS-1503: Clean up connection creation function
The select_connect_backend_servers function is the main connection
creation function. Cleaned it up and split it into smaller, reusable
parts.
2018-04-03 13:30:51 +03:00
a0a37bf793 MXS-1503: Disable reconnection in clientReply
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.
2018-04-03 13:30:50 +03:00
1ddcb15547 MXS-1625 Move RWS specific data out from function
In order to be able to move routing decision into the
query classifier, no RWS specific data can be present.
2018-03-29 13:02:38 +03:00