The functions do not set errno on all invalid input, so it's best to check
endptr.
Also, strtoll is now used for server id scanning through QueryResult.
The worker task should never be immediately executed to allow the task to
be executed on the next "tick" of the worker. This prevents recursive
calls to e.g. routeQuery in readwritesplit when errors are handled.
Only servers that qualify to be connected should be considered as
candidate servers. This triggered a debug assertion when a slave server
failed to execute a session command but it was chosen as a candidate
server later on.
Autoselection is allowed for current master only, or both current and new master.
Autoselection is not allowed for just the new master.
Also, do_switchover() writes to its parameters when autoselecting for
better error messages.
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.
The code failed to compile when the function is used with a warning that
`pBuffer` was used without initialization. This makes sense as the first
conditional block re-declares the same parameter.
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.
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.
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.
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.
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.
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.
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.
The `error` variable was never used. Also added a more convenient typedef
for both the downstream and upstream functions and updated filter API
version.
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.
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.
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.
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.