2229 Commits

Author SHA1 Message Date
Johan Wikman
1da33c4423 MXS-1625 Remove RWS RouteInfo
Now uses the one in QueryClassifier directly.
2018-04-10 17:41:59 +03:00
Johan Wikman
9be98df41c MXS-1625 Move RouteInfo to QueryClassifier 2018-04-10 17:41:59 +03:00
Johan Wikman
91b1ce39b8 MXS-1625 Move routing target bits to QueryClassifier 2018-04-10 17:41:59 +03:00
Markus Mäkelä
948ff9b5f1
MXS-1506: Skip error logging if retrying query
If the query is about to be retried, error logging must be skipped.
2018-04-10 15:32:23 +03:00
Markus Mäkelä
7f05d0ae05
MXS-1506: Refactor causal read reply processing
The state could be factored out into a boolean variable as the reply
processing can be in two states: Either waiting for the response to
MASTER_GTID_WAIT or updating packet numbers.

The packet number updating can always be done as long as a buffer is
available.  The discard_master_wait_gtid_result function discards the OK
packet before the packet numbers are updated so any trailing packets get
corrected properly.
2018-04-10 15:32:23 +03:00
Markus Mäkelä
f124e388fa
MXS-1506: Fix handle_causal_read_reply
The function did not return the changed buffer to the caller of the
function.
2018-04-10 15:32:23 +03:00
Markus Mäkelä
52c55a365e
MXS-1506: Store query if delayed_retry is enabled
The delayed retrying depends on the current query being stored.
2018-04-10 15:32:23 +03:00
Markus Mäkelä
997835c7f8
MXS-1506: Remove mxs::Buffer wrappers from RWSplitSession
Now that the mxs::Buffer has a copy_from for GWBUFs, there's no need to
use wrapper functions. This removes the duplicate code in the wrappers.
2018-04-10 15:32:23 +03:00
Markus Mäkelä
90eeba45df
MXS-1506: Use mxs::Buffer for current query
The mxs::Buffer class already implemented most of the code that was in the
RWSplitSession class.
2018-04-10 15:32:22 +03:00
Markus Mäkelä
196543ef39
MXS-1506: Retry interrupted writes
If a query is interrupted that was sent to the master, it is now
retried. This allows all autocommit queries to be transparently retried if
the server in question fails.
2018-04-10 15:31:51 +03:00
Markus Mäkelä
ed0f20708f
MXS-1506: Release stored buffer
When the session closes, the current query buffer needs to be freed.
2018-04-10 15:31:51 +03:00
Markus Mäkelä
c8d25f293f
MXS-1506: Clean up various functions
Reduced variable scopes and removed unused code.
2018-04-10 15:31:51 +03:00
Markus Mäkelä
d80f60e0af
MXS-1506: Remove delayed_retry_interval
Configuring the parameter current doesn't have enough of an effect to
warrant having a configuration option for it.

Also took mxs::extract_sql into use in the INFO level message.
2018-04-10 15:31:51 +03:00
Markus Mäkelä
1ab8f7a4bf
MXS-1506: Add delayed_retry parameter
By adding a boolean parameter, the feature can be enabled with sensible
default values. Renamed the query_retry parameters and set the defaults to
acceptable values.

Added new parameters to diagnostic output. Also did some minor renaming.
2018-04-10 15:31:50 +03:00
Markus Mäkelä
4786d88413
MXS-1506: Use correct buffer
The GWBUF passed to RWBackend::write must be treated as freed memory if
the write succeeds. This means that the original buffer should be stored,
not the clone.
2018-04-10 15:31:50 +03:00
Markus Mäkelä
e1e01c029c
MXS-1506: Allow immediate query re-routing
Now that the readwritesplit uses the same mechanism for both
retry_failed_reads and delayed query retries, the re-routing function
should accept a delay of 0 seconds. This makes the mechanism more suitable
for other uses e.g. delaying of queries in filters.
2018-04-10 15:31:50 +03:00
Markus Mäkelä
450b31dd8c
MXS-1506: Store queries inside RWSplitSession
As the readwritesplit is the only thing that uses the statement storage,
it can be integrated into RWSplitSession. This makes the code a lot
simpler.
2018-04-10 15:31:50 +03:00
Markus Mäkelä
53dec5323d
Add missing parameters to RWSplit diagnostic output
The new parameters weren't added to the diagnostic output.
2018-04-10 15:31:12 +03:00
Markus Mäkelä
926d029373
MXS-1506: Remove explicit pointer use from diagnostics
As the diagnostics functions are a part of the RWSplit class, there's no
need to use the self pointer.
2018-04-10 15:31:12 +03:00
Markus Mäkelä
ff5b2c85d6
MXS-1506: Simplify logging in connection creation
The logging in the RWSplit::select_connect_backend_servers was quite
cumbersome and doing the logging when the connection is created makes for
a more information rich output (we know what servers were taken into use
and when).

Changed the log messages to use the names of the servers instead of the
address and port.
2018-04-10 15:31:12 +03:00
Markus Mäkelä
d6f98784f7
MXS-1506: Use session_delay_routing with retry_failed_reads
Using the same functionality with the failed read retrying mechanism
removes the need to have multiple versions of the target deduction logic.
2018-04-10 15:31:11 +03:00
Markus Mäkelä
34008082e5
Rename to has_session_commands
This way it is similar to other member functions.
2018-04-10 15:30:28 +03:00
Markus Mäkelä
951a55ef43
Format readwritesplit source code
Formatted all files with Astyle.
2018-04-10 15:30:27 +03:00
Markus Mäkelä
dc338ff3f2
Move causal read reply processing into sub-function
This makes the clientReply a lot easier to comprehend.
2018-04-10 15:29:31 +03:00
Markus Mäkelä
465a17d439
MXS-1503: Remove false debug assertion
It is possible that the routing fails even if master_reconnection is
enabled and a second master is available. This is the case when a
transaction is open or autocommit is disabled which is what the
mxs359_master_switch test tests.
2018-04-10 15:29:31 +03:00
Markus Mäkelä
e5e607908d
MXS-1506: Add router to MXS_DOWNSTREAM helper function
The function makes it easier to deal with the delayed query routing as
well as removing redundancy in the code.
2018-04-10 15:29:30 +03:00
Markus Mäkelä
c70216390f
MXS-1506: Combine housekeeper task types
The tasks themselves now control whether they are executed again. To
compare it to the old system, oneshot tasks now return `false` and
repeating tasks return `true`.

Letting the housekeeper remove the tasks makes the code simpler and
removes the possibility of the task being removed while it is being
executed. It does introduce a deadlock possibility if a housekeeper
function is called inside a housekeeper task.
2018-04-10 15:29:30 +03:00
Markus Mäkelä
96a0aae7fe
MXS-1506: Move all functionality into Housekeeper
The class now does all of the work and the API wraps the calls to the
member methods. Using an STL container makes the list management a lot
more convenient.
2018-04-10 15:29:30 +03:00
Markus Mäkelä
b33f464eea
MXS-1506: Make heartbeat reads atomic
The old hkheartbeat variable was changed to the mxs_clock() function that
simply wraps an atomic load of the variable. This allows it to be
correctly read by MaxScale as well as opening up the possibility of
converting the value load to a relaxed memory order read.

Renamed the header and associated macros. Removed inclusion of the
heartbeat header from the housekeeper header and added it to the files
that were missing it.
2018-04-10 15:29:29 +03:00
Markus Mäkelä
761fda2806
Add delayed query retry prototype
This is a proof-of-concept that validates the query retrying method. The
actual implementation of the query retrying mechanism needs more thought
as using the housekeeper is not very efficient.
2018-04-10 15:29:29 +03:00
Johan Wikman
d65af04d19 MXS-1625 Make as much private as possible in QueryClassifier
Some stuff that is manipulated from RWS must be left public
for the time being.
2018-04-10 14:14:55 +03:00
Johan Wikman
563a33ae56 MXS-1625 Move get_target_type() to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
42e72bfb81 MXS-1625 Move handle_multi_temp_and_load to QueryClasifier 2018-04-10 14:14:55 +03:00
Johan Wikman
369029b612 MXS-1625 Move check_for_multi_stmt to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
9a6d66f104 MXS-1625 Move functions to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
505d6b5889 MXS-1625 Move check_create_tmp_table() to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
c8673bc0b3 MXS-1625 Move determine_query_type() to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
18ca7018b1 MXS-1625 Move log_transaction_status() to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
5689613801 MXS-1625 Hint-handling moved to QueryClassifier 2018-04-10 14:14:55 +03:00
Johan Wikman
c8961a3d14 MXS-1625 Move QueryClassifier::Handler to RWSplitSession 2018-04-10 14:14:55 +03:00
Johan Wikman
a102ddf5de MXS-1625 Remove final traces of RWSplitSession
The code for figuring out the where to send a statement does no
longer depend upon RWSplitSession but only on QueryClassifier.
So now the functionality can be moved into QueryClassifier after
which further cleanup and streamlining can be done.
2018-04-10 14:14:55 +03:00
Johan Wikman
300de4ecc6 MXS-1625 Move internal/external id map to QueryClassifier 2018-04-10 14:14:55 +03:00
Markus Mäkelä
304499bd36
Merge branch '2.2' into develop 2018-04-10 14:05:39 +03:00
Johan Wikman
36bea39b63 MXS-1625 Remove need for RWS session from handle_multi_temp_and_load() 2018-04-05 15:05:04 +03:00
Johan Wikman
05a6aa2dea MXS-1625 Remove need for RWS session in helper functions 2018-04-05 14:04:30 +03:00
Johan Wikman
00ee271656 MXS-1625 Remove need for RWS session in log_transaction_status() 2018-04-05 13:54:37 +03:00
Johan Wikman
08987e3e85 MXS-1625 Remove need for RWS session in check_create_tmp_table 2018-04-05 13:42:39 +03:00
Johan Wikman
1133173a65 MXS-1625 Move tmp table management to QueryClassifier
Eventually only managed by QueryClassifier.
2018-04-05 13:38:55 +03:00
Johan Wikman
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
Johan Wikman
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