10177 Commits

Author SHA1 Message Date
Esa Korhonen
7f36339f53 MXS-1703 Better strtoll() & strtoull() error detection
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.
2018-04-12 13:06:36 +03:00
Esa Korhonen
ca9682f042 MXS-1703 Reorganize cluster manipulation methods
Just moving code around.
2018-04-12 13:06:36 +03:00
Esa Korhonen
4ba79e8d49 MXS-1703 Cleanup cluster manipulation code
Server arrays use the MariaDBServer type.
2018-04-12 13:06:22 +03:00
Markus Mäkelä
526d57049b
Add backend name to info level messages
The messaged that logged the URI of the backend now also log the name of
the backend.
2018-04-12 11:20:37 +03:00
Markus Mäkelä
385a221194
MXS-1506: Add cluster failure test
The test exercises the retrying code by failing both nodes.
2018-04-12 10:42:40 +03:00
Markus Mäkelä
3aa62b0116
MXS-1506: Always queue the delayed routing task
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.
2018-04-12 10:42:40 +03:00
Markus Mäkelä
553e159182
MXS-1503: Test that no extra slaves are taken into use
Added a test that verifies that the slave connection count restrictions
work.
2018-04-12 10:42:39 +03:00
Markus Mäkelä
dc3c848df8
Pick servers that can be connected to as candidates
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.
2018-04-12 10:42:39 +03:00
Esa Korhonen
b34e0000b4 MXS-1768 Allow autoselect for new master in switchover
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.
2018-04-12 10:04:36 +03:00
Esa Korhonen
d8a16dfe21 MXS-1703 Cleanup manual cluster modification command handling
Switchover checks are performed after monitor is stopped to be analogous to
other operations.
2018-04-12 10:04:36 +03:00
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ä
eafdd61888
MXS-1506: Test interrupted SELECTs
Expanded the test to cover interrupted SELECT statements.
2018-04-10 15:32:24 +03:00
Markus Mäkelä
15bb90afc4
MXS-1506: Extend test case
Extended test case to cover interrupted writes.
2018-04-10 15:32:24 +03:00
Markus Mäkelä
93f589ffa2
MXS-1506: Add test case
Added a test case that performs basic testing of the functionality.
2018-04-10 15:32:23 +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ä
23aa9cc492
Add Buffer::copy_from(GWBUF*)
This makes it easier to create a Buffer from GWBUF that the API functions
pass as arguments.
2018-04-10 15:32:23 +03:00
Markus Mäkelä
f06b2b5ab9
Fix mxs::Buffer::copy_from
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.
2018-04-10 15:32:22 +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ä
23bc8b6db6
MXS-1506: Document delayed_retry
Document the parameters and how they interact with `master_reconnection`.
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ä
b9c0f0ffd2
Add mxs::extract_sql
The helper function extracts the SQL contents as std::string from a
buffer. This should make it easier to log the query in C++ code.
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ä
cc793b2151
MXS-1506: Remove unused MXS_UPSTREAM variables
The `error` variable was never used. Also added a more convenient typedef
for both the downstream and upstream functions and updated filter API
version.
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ä
67b2f24be1
MXS-1506: Move housekeeping into Housekeeper class
Moved the main task processing code into a class.
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
Markus Mäkelä
e76b00e340
Merge branch '2.2' into develop 2018-04-10 15:28:00 +03:00