85 Commits

Author SHA1 Message Date
Markus Mäkelä
e311b86800
MXS-1826: Respond with AuthSwitchRequest to COM_CHANGE_USER
To support a wider range of client connectors, MaxScale should respond
with an AuthSwitchRequest packet to all COM_CHANGE_USER commands. Only
MariaDB connectors understand the OK packet as the only response to a
COM_CHANGE_USER but all connectors understand the AuthSwitchRequest
packet.
2018-05-03 09:50:52 +03:00
Markus Mäkelä
66d7281d97
MXS-1846: Send correct packet number in errors
The mysql_create_standard_error function accepted a packet number as a
parameter but did not use it as the actual packet number. As the value it
used happened to coincide with 50% of the use-cases, it went unnoticed.

The remaining 50% occurred when a KILL command was executed with an
unknown connection ID.
2018-05-03 09:50:51 +03:00
Markus Mäkelä
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
Markus Mäkelä
490d8c0963
Merge branch '2.2' into develop 2018-04-30 12:38:19 +03:00
Markus Mäkelä
452f2190ae
MXS-1826: Handle Authswitch packet for COM_CHANGE_USER
If the server responds with a COM_CHANGE_USER to the default
authentication plugin, the backend protocol will answer correctly.
2018-04-29 10:42:12 +03:00
Markus Mäkelä
43a99886e9
Fix SESSION_TRACK_SCHEMA tracking
The SESSION_TRACK_SCHEMA tracking capability handling assumed an encoding
integer in the data. This value does not exist for the data returned by
schema change or session state tracking.
2018-04-20 10:24:00 +03:00
Markus Mäkelä
ec33fcf87d
Merge branch '2.2' into develop 2018-04-13 14:53:00 +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ä
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ä
6ef9e1fd9a
Move RWBackend into a separate file
Moved the RWBackend class implementation into its own file. Made some of
the command type functions a part of the <maxscale/protocol/mysql.h>
header to make it reusable.
2018-04-03 13:30:55 +03:00
Markus Mäkelä
10a9d70851
Get service capabilities from a better source
The DCB pointer in the MySQLProtocol struct doesn't appear to be updated
in all cases which causes it to be an unreliable source. As the session
itself is always available and it always has the service pointer properly
set, it should be used instead.

Also removed the dead protocol compression code and replaced the
parameters with the service capability bits.
2018-03-20 13:42:25 +02:00
Markus Mäkelä
20c5ca1619
Make session state change tracking conditional
By making it conditional, we prevent the problems that arise when the
replication protocol is used in combination with the session state change
tracking. In addition to this, it prevents unnecessary work for routers
and filters that don't need it.
2018-03-20 13:42:24 +02:00
Markus Mäkelä
d6b8147119
Merge branch '2.2' into develop 2018-03-06 17:02:03 +02:00
Markus Mäkelä
d5226fa7d1
MXS-1698: Fix double SSL connection
When backend SSL connections were created, the connection creation was
done twice. This was due to the lacking detection of an already
established SSL connection.
2018-03-06 13:35:15 +02:00
dapeng
8a0c8e63f2 MXS-199: Support Causal Read in Read Write Splitting (#164)
* MXS-199: Support Causal Read in Read Write Splitting

* move most causal read logic into rwsplit router and get server type from monitor

* misc fix: remove new line

* refactor, move config to right place, replace ltrim with gwbuf_consume

* refacter a little for previous commit

* fix code style
2018-02-05 09:09:18 +02:00
Dapeng Huang
a035c91fa6 add doc for session_track_trx_state and refactor little 2018-01-29 10:16:03 +02:00
Markus Mäkelä
7b04d17ce3 Use correct function for consuming LEncStrings
Length-encoded strings should be consumed with the correct
functions. Doing pointer arithmetic with the same pointer as a parameter
appears to fail only on CentOS 6 whereas on newer systems it performs as
expected.
2018-01-24 20:30:02 +02:00
Markus Mäkelä
dfbecc41e2 Format protocol modules
Formatted the MariaDB protocol modules with Astyle.
2018-01-24 11:20:11 +02:00
Dapeng Huang
73e5fd52fa misc fix and remove all tail spaces 2018-01-22 22:02:22 +08:00
Dapeng Huang
1729d73b19 revert deprecate eof 2018-01-22 20:28:50 +08:00
Dapeng Huang
f41f3a1544 support deprecated eof and fix eof count 2018-01-22 20:20:52 +08:00
Dapeng Huang
81f303512e check protocol state to determine real ok packet 2018-01-22 14:52:12 +08:00
Dapeng Huang
8ce7683a0a fix parse session track info out of packet boundary 2018-01-21 18:27:00 +08:00
Dapeng Huang
f7e08fdb47 add doc, more detail about trx state 2018-01-16 15:14:29 +08:00
Dapeng Huang
f1aa1d7d9f fix code style 2018-01-16 14:56:51 +08:00
Dapeng Huang
a52e1ac8d7 add session tracker:SESSION_TRACK_TRANSACTION_CHARACTERISTICS and fix wrong state mapping 2018-01-16 13:56:00 +08:00
Dapeng Huang
6d3c60eb28 remove noneed protocol and the comparison corrent 2018-01-15 22:07:23 +08:00
Dapeng Huang
d234b13027 refactor, check every packet before parser ok packet, move config to service, fix code style, ... 2018-01-15 20:25:44 +08:00
Dapeng Huang
e1aeac8b07 get session transation state from backend via session track mechanism 2018-01-14 12:23:38 +08:00
Markus Mäkelä
ca0b9de421 Add missing initialization of MySQLProtocol::collect_result
The variable was not initialized.
2017-10-12 12:29:43 +03:00
Johan Wikman
87c01428be Make mxs_mysql_get_command inline 2017-10-12 12:29:43 +03:00
Markus Mäkelä
a6eeed98fe Fix handling of collected results
The result collection did not reset properly when a non-resultset was
returned for a request. As collected result need to be distinguishable
from single packet responses, a new buffer type was added.

The new buffer type is used by readwritesplit which uses result collection
for preparation of prepared statements.

Moved the current command tracking to the RWBackend class as the command
tracked by the protocol is can change before a response to the executed
command is received.

Removed a false debug assertion in the mxs_mysql_extract_ps_response
function that was triggered when a very large prepared statement response
was processed in multiple parts.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
96d160f897 MXS-1452: Add support for KILL USER <name>
Added support for killing queries by username. This will kill all
connections from that particular user on all servers.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
49b179bf69 Add HARD/SOFT to executed KILL commands
The HARD and SOFT keywords are parsed and added to the executed KILL
commands.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
4dd6842447 Send KILL commands to backends
KILL commands are now sent to the backends in an asynchronous manner. As
the LocalClient class is used to connect to the servers, this will cause
an extra connection to be created on top of the original connections
created by the session.

If the user does not have the permissions to execute the KILL, the error
message is currently lost. This could be solved by adding a "result
handler" into the LocalClient class which is called with the result.
2017-10-03 14:47:16 +03:00