10205 Commits

Author SHA1 Message Date
Johan Wikman
fa3143cedf Merge branch '2.2' into develop 2018-04-16 14:46:19 +03:00
Esa Korhonen
9b7ec7ee58 MXS-1703 Add missing manual rejoin error messages
Calling rejoin with a server which is already replicating now gives a proper error
message.
2018-04-16 13:52:23 +03:00
Esa Korhonen
ba23aa9ce5 MXS-1703 Update monitor documentation
Clarify some parts and add note of switchover master autoselection. Also update
release notes.
2018-04-16 13:48:56 +03:00
Esa Korhonen
c43f64c87e MXS-1703 Cleanup more methods
Most monitor functions now work with the monitor's own server class.
2018-04-16 13:48:56 +03:00
Johan Wikman
7e29725050 MXS-1805 Force all maxadmin connections to main thread
If maxadmin connections are handled by different workers, then
there may be a deadlock if some maxadmin command requires
communication with all workers.

Namely, in that case a message will be sent to all other workers
but the current one, but that message will not be handled if that
other worker at that point sits in the debugcmd_lock spinlock
in debugcmd.c:execute_cmd().

We can prevent that deadlock from happening simply by ensuring
that all maxadmin connections are handled by one thread.
2018-04-16 13:25:33 +03:00
Markus Mäkelä
ec33fcf87d
Merge branch '2.2' into develop 2018-04-13 14:53:00 +03:00
Johan Wikman
3d8d2beaaa MXS-1787 Provide alias map when parsing an expression list
A statement like "CALL p1((SELECT f1()), ?);" needs an collection
for storing aliases when being parsed.
2018-04-13 13:50:28 +03:00
Johan Wikman
94af85b948 MXS-1787 Add test that exposes problem 2018-04-13 13:50:28 +03:00
Esa Korhonen
3c8d3feff9 MXS-1703 Run astyle, rewrite comments & reorder fields
No functional changes.
2018-04-13 13:33:13 +03:00
Esa Korhonen
4d6239635e MXS-1703 Add and use convenience functions for common macros/fields
Also add debug assert to MariaDBServer ctor.
2018-04-13 13:31:12 +03:00
dapeng huang
3d09c836c5 init inst->sessions for maxinfo (#173)
* init inst->sessions for maxinfo

* misc fix
2018-04-13 12:58:02 +03:00
Esa Korhonen
f7cc2aed5a MXS-1703 Remove MariaDBServer value array type
Having two types of arrays was more trouble than worth. Clearer to just
use the array of pointers. Renamed ServerRefArray to ServerArray.
2018-04-13 10:08:57 +03:00
Esa Korhonen
9fe57bfb9b MXS-1703 Change type of m_master to MariaDBServer 2018-04-13 10:08:57 +03:00
Markus Mäkelä
e3b11d866f
Use explicit types with get_row
Auto types aren't very neat as return values because they move the burden
of knowledge to the reader. Using an explicit, and somewhat
self-explanatory, type makes it easier to assess the code without knowing
the implementation of the type.
2018-04-13 08:48:21 +03:00
Markus Mäkelä
b060e3a289
MXS-1787: Add test case
Added a test case that reproduces the problem.
2018-04-12 20:36:46 +03:00
Markus Mäkelä
802b16f709
MXS-1786: Fix hang on COM_STATISTICS
The commands needs to be handled separately from the rest of the result
types.

Added a test case that reproduces the problem and verifies that the change
in code fixes it.
2018-04-12 20:00:00 +03:00
Markus Mäkelä
1a293c0093
MXS-1785: Don't assume empty packet is for LDLI
When a LOAD DATA LOCAL INFILE finishes, the client sends an empty
packet. The second case when the client sends an empty packet when the
previous packet was exactly 0xffffff bytes long. These two packets were
confused which caused the internal state to temporarily flip from inactive
to ending and back to inactive.

The aforementioned flip-flopping didn't have any practical differences but
it was caught by a debug assertion.
2018-04-12 19:36:34 +03:00
Esa Korhonen
b6e421e13b MXS-1703 Use a common header for all mariadbmon files
The mariadb_common.hh file is now a header with only common definitions
such as module name. The QueryResult-class was moved to MariaDBServer.
2018-04-12 13:06:36 +03:00
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
Markus Mäkelä
a663ea2e80
Sync slaves in mxs1071_maxrows
The first test could fail due to replication lag.
2018-04-12 10:29:26 +03:00
Markus Mäkelä
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
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
Markus Mäkelä
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
Markus Mäkelä
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
Markus Mäkelä
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
Markus Mäkelä
252475cdc5
MXS-1776: Add test case
Added test case that reproduces the problem.
2018-04-11 15:13:20 +03:00
Markus Mäkelä
c0a3e6ba37
MXS-1773: Add test case
Added a test case that reproduces the problem and verifies that it is
fixed.
2018-04-11 09:45:13 +03:00
Markus Mäkelä
8e2208b957
Update limitations document
Removed old limitations from the document and cleaned up some of the text.
2018-04-11 09:25:29 +03:00
Markus Mäkelä
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
Markus Mäkelä
e327282e82
Don't log warnings for valid SQL
The warnings are about what the parser expects, not something the end user
should know.
2018-04-10 21:39:46 +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