Commit Graph

2307 Commits

Author SHA1 Message Date
be098538e5 MXS-1881: Read event header in a separate function
Reading the binlog event header in a separate function makes it easier to
comprehend. Cleaned up some unused variables and code that would is not
used.
2018-05-28 10:32:18 +03:00
5a3bbf0d15 Move binlog event processing into a separate file
This clarifies what parts of the router are specific to the binlogrouter
and what are common between the binlogrouter and avrorouter.

Ideally, the two modules would use the same infrastructure to handle the
processing of replication events. This is the first, albeit small, step
towards making the code in the binlogrouter the common infrastructure.
2018-05-28 10:32:18 +03:00
14a3b0052b MXS-1881: Perform task management in main worker
The creation and cancellation of delayed tasks must be done on the worker
where the task is executed.
2018-05-28 10:32:18 +03:00
ec919c367b Move Avro creation into Avro::create
The Avro instance is now created inside a static class method. This brings
it in line with how other modules create instances.

Converted all strings to std::string and updated their usage.
2018-05-28 10:32:17 +03:00
232d86e67a Make active table map array dynamic
By storing the table maps in a std::unordered_map, the storage of mapped
tables is made dynamic. This also makes the management of mapped tables a
lot more robust.
2018-05-28 10:32:17 +03:00
f8ceb875a0 Refactor TABLE_CREATE allocation
Using std::string for names removes the need to handle memory
allocation. Moving the column attributes into a class of its own greatly
simplifies the creation of the TABLE_CREATE as well as modifications that
are done to it.
2018-05-28 10:32:17 +03:00
d5760f4301 Move AvroSession initialization inside the class
The AvroSession now has the AvroSession::create method for creation new
sessions. The destructor handles the freeing of all allocated resources.
2018-05-28 10:32:16 +03:00
fb53bbf4da Use STL containers in avrorouter
The HASHTABLE can be replaced with std::unordered_map. This simplifies the
management by making the deletion of old objects automatic.

More cleanup and refactoring is needed to make the contained classes
cleaner.
2018-05-28 10:32:16 +03:00
a6eef98597 Initialize all AvroSession variables
This is done to get tests to pass before further refactoring is done.
2018-05-28 10:32:16 +03:00
6159f863ce Remove unnecessary locking
The lock didn't really protect anything but since it was not explicitly
initialized, it caused a hang.
2018-05-28 10:32:16 +03:00
3fce61a615 Do avro conversion in main thread
The avrorouter no longer uses the housekeeper for the conversion
task. This prevents the deadlock which could occur when clients were
notified at the same time that the binlogrouter was adding a master
reconnection task.
2018-05-28 10:32:16 +03:00
16d2ff9564 Set read and execute permissions for all paths
If a path requires read or execute permission, it is granted to all. This
keeps path parameters in line with other directories that MaxScale
creates.
2018-05-28 10:32:16 +03:00
6898397d49 Clean up avrorouter.hh
Cleaned up the header and removed most of unused member variables.
2018-05-28 10:32:15 +03:00
8dd89548f4 Fix avrorouter client notification
The avrorouter client notification now uses dcb_foreach.
2018-05-28 10:32:15 +03:00
3095b18b14 Convert avrorouter objects to C++
The instance and session objects are now C++ structs. The next pointers
for the sessions was removed as it is not the appropriate place to store
this information. This means that the client notification functionality is
broken in this commit.
2018-05-28 10:32:15 +03:00
354e9aeefc Clean up avrorouter files
Removed commented out code, manual revision notes and extraneous comments.
2018-05-28 10:32:15 +03:00
77c713baa6 Remove manual revision notes and extra files
Removed the manually written revision notes that were in some files. Also
removed the README and STATUS files which were present.
2018-05-28 10:32:14 +03:00
d9b61f9f15 Use std::list instead of std::deque
The copying of a std::deque appears to cause problems on CentOS 6. Using
an std::list seems to work without problems.
2018-05-23 13:09:15 +03:00
88380038c1 Fix regression in handling of large packets
When large binary protocol packets were handled, a part of the data was
replaced with a non-existing PS ID.

The replacement of the client PS ID to the internal ID and the replacement
of the internal ID to the server specific ID must only be done if a large
packet is not being processed. This can be done on the router level
without adding knowledge of large packets to the RWBackend class.

A specific function, RWBackend::continue_write, was added to make it clear
that the buffer being written is a part of a larger query. The base class
Backend::write could be used but its usage is not self-explanatory.
2018-05-22 17:46:27 +03:00
a33f09ad06 Fix test failures and add debug logging
Fixed test failures, increased some of the timeouts, added extra info
level logging into rwsplit to help debug the test failures.
2018-05-22 17:46:27 +03:00
730fd9f30d MXS-1778: Rename variables and change default values
The causal read timeout now has a default value of 120 seconds. Removed
the redundant `enable` part from the names of the member variables.
2018-05-22 17:46:26 +03:00
4ba0ac434b MXS-1778: Add support for MariaDB GTID tracking
The MariaDB implementation allows the last GTID to be tracked with the
`last_gtid` variable. To do this, the configuration option
`session_track_system_variables=last_gtid` must be used or it must be
enabled at runtime.
2018-05-22 17:46:26 +03:00
df7c46fbdd Merge branch '2.2' into develop 2018-05-18 12:45:15 +03:00
3cb389a3b5 MXS-1866: Add support for COM_STMT_BULK_EXECUTE
Readwritesplit now detects the COM_STMT_BULK_EXECUTE command and handles
it correctly.
2018-05-18 12:30:24 +03:00
8067f312a1 MXS-1873: Collect results for all session commands
To work around the limitation in the session command handling and
multi-part results, all session commands are now treated as gathered
results. This allows session commands which return result sets to be used
with MaxScale.

This change should not cause problems with practical workloads as they
usually do not return massive resultsets for session commands.

The optimal way to handle the multi-part responses would be to integrate
it into the result completion tracking process. This would allow the
prepared statement IDs to be extracted while the command is being
processed.
2018-05-18 12:29:34 +03:00
91cc5b1e89 MXS-1828: Simplify LOAD DATA LOCAL INFILE handling
By relying on the server to tell us that it is requesting the loading of a
local infile, we can remove one state from the state machine that governs
the loading of local files. It also removes the need to handle error and
success cases separately.

A side-effect of this change is that execution of multi-statement LOAD
DATA LOCAL INFILE no longer hangs. This is done by checking whether the
completion of one command initiates a new load.

The current code recursively checks the reply state and clones the
buffers. Neither of these are required nor should they be done but
refactoring the code is to be done in a separate commit.

Added two helper functions that are used to detect requests for local
infiles and to extract the total packet length from a non-contiguous
GWBUF.
2018-05-18 09:46:07 +03:00
12035289f4 Remove server authenticator options
Was unused. A warning is printed if the parameter is defined. Any value is ignored.
2018-05-08 14:18:00 +03:00
510eb7ec7c MXS-1848 Change monitorCamelCase to monitor_snake_case 2018-05-07 14:08:36 +03:00
1f6cc6db8a MXS-1840 Compile all routers as C++
Minimal changes, only what is needed in order to make it compile.
2018-05-07 14:06:22 +03:00
658329b648 Merge branch '2.2' into develop 2018-05-03 10:00:44 +03:00
121d255780 Add protocol packet statistics to servers
The individual servers were missing a statistic that would give an
estimated query count. As there is no simple way to count queries for all
modules, counting the number of routed protocol packets is a suitable
substitute.
2018-05-03 09:50:45 +03:00
d6c44aaf52 MXS-1804: Allow large session commands
Session commands that span multiple packets are now allowed and will
work. However, if one is executed the session command history is disabled
as no interface for appending to session commands exists.

The backend protocol modules now also correctly track the current
command. This was a pre-requisite for large session commands as they
needed to be gathered into a single buffer and to do this the current
command had to be accurate.

Updated tests to expect success instead of failure for large prepared
statements.
2018-05-03 09:46:47 +03:00
ff8a7c8b93 MXS-1507: Add transaction replay statistics
Added a simple counter for the number of replayed transactions.
2018-05-03 09:46:46 +03:00
8a52478afa Remove redundant diagnostic output
Readwritesplit had redundant parameter values in the
`router_diagnostics`. All module parameters with their current values are
already displayed in the `parameters` member of the resource.
2018-05-03 09:46:46 +03:00
8ad3b903f9 Fix hang with large COM_STMT_SEND_LONG_DATA
The router did not take large packets into account when determining
whether the server will respond. This caused the response counts to be off
by one for all large packets.
2018-05-03 09:46:40 +03:00
9ba9322b9b MXS-1752: Make cat experimental
The cat router is now a part of the experimental module package.
2018-04-27 12:31:52 +03:00
88ae276dd6 MXS-1752: Fail if no connections were created
If no backend connections were created, the CatSession will not be
created.
2018-04-27 12:31:49 +03:00
89df068ed5 MXS-1752: Remove EOF packet generation
The creation of the EOF packet is not needed as the last packet of a
result set is always guaranteed to be of the correct type. This also
allows non-resultsets to be correctly processed as the internal packet
number will be at 0 when the last result arrives.

Cleaned up some of the function names and changed the signatures to be
better suited for their use-cases.

Use angle bracket includes, combine some of the more unwieldly
conditionals into functions, added more comments.
2018-04-27 12:31:49 +03:00
4966fb9e96 MXS-1752: Add prototype concatenation router
The router concatenates multiple result sets.
2018-04-27 12:31:48 +03:00
e01cfe0fba Remove avrorouter deadlock
The avrorouter would attempt to enable the conversion task from within the
conversion task itself. This caused a deadlock which led to test failures.
2018-04-27 12:00:38 +03:00
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
880e0fb74e Merge branch '2.2' into develop 2018-04-26 16:39:00 +03:00
c97d2c94eb MXS-1825: Fix PS output parameter tracking for MySQL variants
The resultset processing for MySQL requires some extra work as it lacks
the proper SERVER_MORE_RESULTS_EXIST flag in the last EOF packet. Instead,
the first EOF packet has the SERVER_PS_OUT_PARAMS flag which needs to be
interpreted as a SERVER_MORE_RESULTS_EXIST flag for the second EOF packet.

Also corrected the EOF packet handling to do the flag checks in the code
that deals with the EOF packets.

As the modutil_state parameter is now used for more than large packet
tracking, the correct solution is to store this state object in the
readwritesplit session instead of interpreting it to a boolean value.
2018-04-26 16:02:09 +03:00
260fcf85ec Remove false debug assertion
A prepared statement ID of 0 is allowed.
2018-04-26 16:02:09 +03:00
0df326d581 MXS-1824: Track only the opening of cursors
Whether a cursor is open or not does not matter as long as the attempt to
open a cursor is detected.
2018-04-26 16:02:09 +03:00
092532745d MXS-1507: Add transaction size limit
Added the `transaction_replay_max_size` parameter that controls the
maximum size of a transaction that can be replayed. If the limit is
exceeded, the stored statements are released thus preventing the
transaction from being replayed.

This limitation prevents accidental misuse of the transaction replaying
system when autocommit is disabled. It also allows the user to control the
amount of memory that MaxScale will use.
2018-04-26 13:44:26 +03:00
7de7e7b2fe MXS-1507: Replay read-only transaction
Read-only transactions are now replayed if the node in question fails.
2018-04-26 13:44:25 +03:00
2848f96945 MXS-1507: Make transaction replay configurable
The transaction retrying behavior is now configurable and documented. The
`transaction_replay` parameter implicitly enables the required
functionality in the router that it needs.
2018-04-26 13:44:25 +03:00
c1c942a058 MXS-1507: Retry interrupted queries in transactions
As the current query was added to the transaction log before it finished,
the m_current_query contained a duplicate of the latest transaction log
entry. To correctly log only successful transactions, the statement should
be added only after it has successfully completed. This change also
removed the unnecessary cloning that took place when the statement was
added to the log before it finished.

With the fixed transaction logging, the value of m_current_query can be
stashed for later retrying while the replay process is happening. If the
replay completes successfully and the checksums match, the interrupted
query is retried.

Also added a clarifying comment to can_retry_query to explain why a query
inside a transaction cannot be retried.
2018-04-26 13:44:25 +03:00
01bf5cc8b0 MXS-1507: Add initial implementation of transaction replay
Added the initial implementation of transaction replay. Transactions are
only replayed if the master fails when no statement is being executed.

The validity of the replayed transaction is done by verifying that the
checksums of the returned results are equal.

Added a close function into the Trx class to make resetting its state
easier. Also changed the return type of the pop_stmt to GWBUF* as the
places where it is used expect a raw GWBUF pointer.
2018-04-26 13:44:25 +03:00