Commit Graph

2285 Commits

Author SHA1 Message Date
da03c73373 MXS-1776: Fix COM_STMT_EXECUTE flag extraction
The code extracted the statement id, not the flags.
2018-04-12 10:25:10 +03:00
fab8477c05 MXS-1776: Fix utility functions
The COM_STMT_FETCH command will create a response. This was a
readwritesplit-specific interpretation of the command and it was wrong.

Also record the currently executed command event for session commands.
2018-04-12 09:44:28 +03:00
ad5458f0e7 MXS-1776: Initialize RWBackend::m_command
The variable was not initialized which caused COM_CHANGE_USER to produce
unexpected behavior.
2018-04-12 09:43:38 +03:00
311adf817f MXS-1776: Handle recursive COM_STMT_EXECUTE commands
Readwritesplit would not handle multiple overlapping COM_STMT_EXECUTE
commands properly if they opened cursors. This was due to the fact that
the result would not be marked as complete and COM_STMT_FETCH commands
were executed as if they did not return results.

The correct implementation is to consider a COM_STMT_EXECUTE that opens a
cursor complete only when the first EOF packet is read (that is, when the
resultset header is read). This allows subsequent COM_STMT_FETCH commands
to be handled separately.

The separate COM_STMT_FETCH handling must count the number of packets that
are being fetched. This allows correct tracking of the state of a
COM_STMT_FETCH by checking that the number of packets is correct or the
second EOF/ERR packet is read.
2018-04-11 15:26:37 +03:00
1eefb46e68 MXS-1773: Update internal state when LOAD DATA LOCAL INFILE fails
When a LOAD DATA LOCAL INFILE is actively rejected by the server, the
server sends an error to the client. This error was not detected and the
router was stuck in the special mode that handles LOAD DATA LOCAL INFILE.
2018-04-11 09:25:23 +03:00
1da33c4423 MXS-1625 Remove RWS RouteInfo
Now uses the one in QueryClassifier directly.
2018-04-10 17:41:59 +03:00
9be98df41c MXS-1625 Move RouteInfo to QueryClassifier 2018-04-10 17:41:59 +03:00
91b1ce39b8 MXS-1625 Move routing target bits to QueryClassifier 2018-04-10 17:41:59 +03:00
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
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
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
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
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
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
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
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
c8d25f293f MXS-1506: Clean up various functions
Reduced variable scopes and removed unused code.
2018-04-10 15:31:51 +03:00
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
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
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
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
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
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
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
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
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
34008082e5 Rename to has_session_commands
This way it is similar to other member functions.
2018-04-10 15:30:28 +03:00
951a55ef43 Format readwritesplit source code
Formatted all files with Astyle.
2018-04-10 15:30:27 +03:00
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
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
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
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
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
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
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
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
563a33ae56 MXS-1625 Move get_target_type() to QueryClassifier 2018-04-10 14:14:55 +03:00
42e72bfb81 MXS-1625 Move handle_multi_temp_and_load to QueryClasifier 2018-04-10 14:14:55 +03:00
369029b612 MXS-1625 Move check_for_multi_stmt to QueryClassifier 2018-04-10 14:14:55 +03:00
9a6d66f104 MXS-1625 Move functions to QueryClassifier 2018-04-10 14:14:55 +03:00
505d6b5889 MXS-1625 Move check_create_tmp_table() to QueryClassifier 2018-04-10 14:14:55 +03:00
c8673bc0b3 MXS-1625 Move determine_query_type() to QueryClassifier 2018-04-10 14:14:55 +03:00
18ca7018b1 MXS-1625 Move log_transaction_status() to QueryClassifier 2018-04-10 14:14:55 +03:00
5689613801 MXS-1625 Hint-handling moved to QueryClassifier 2018-04-10 14:14:55 +03:00
c8961a3d14 MXS-1625 Move QueryClassifier::Handler to RWSplitSession 2018-04-10 14:14:55 +03:00
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
300de4ecc6 MXS-1625 Move internal/external id map to QueryClassifier 2018-04-10 14:14:55 +03:00
304499bd36 Merge branch '2.2' into develop 2018-04-10 14:05:39 +03:00
36bea39b63 MXS-1625 Remove need for RWS session from handle_multi_temp_and_load() 2018-04-05 15:05:04 +03:00
05a6aa2dea MXS-1625 Remove need for RWS session in helper functions 2018-04-05 14:04:30 +03:00