46 Commits

Author SHA1 Message Date
Markus Mäkelä
a812e02ba4
Merge branch '2.2' into develop 2018-06-15 10:48:07 +03:00
Markus Mäkelä
3d1c2b421a
MXS-1921: Explain why session was closed
When a client connection is closed by MaxScale before the client initiates
a controlled closing of the connection, an error message is sent. This
error message now also explains why the connection was closed to make
problem resolution easier.
2018-06-14 13:48:07 +03:00
Markus Mäkelä
8094c67ac2
Merge branch '2.2' into develop 2018-06-13 00:25:56 +03:00
Markus Mäkelä
e99d9826ad
Fix route_by_statement return value
The return value of route_by_statement was not initialized and not set if
a COM_CHANGE_USER was processed.
2018-06-12 23:55:30 +03:00
Markus Mäkelä
3f4d6391b5
MXS-553: Add diagnostics_json to protocol API
The protocol now allows protocol modules to return JSON formatted
information about the protocol module internals. Currently this is only
implemented by the mariadbbackend module and it returns the current
connection ID on the backend server.
2018-05-22 17:46:25 +03:00
Markus Mäkelä
cdb43335a2
MXS-553: Update and document the protocol API
Removed unused and properly documented all entry points in the protocol
module API. As the removal of the `session` entry point is an backwards
incompatible change, the protocol API version was updated.
2018-05-22 17:46:25 +03:00
Johan Wikman
7e9062f20f Merge branch '2.2' into develop 2018-05-16 09:31:13 +03:00
Johan Wikman
b5888d8950 Merge branch '2.1' into 2.2 2018-05-16 09:23:54 +03:00
Markus Mäkelä
10806f8d8c
Update client SHA1 on reauthentication
When the client reauthenticates via COM_CHANGE_USER the new SHA1 needs to
be stored as the backend connections rely on it being up-to-date.

This commit fixes the regression of the mxs548_short_session_change_user
test.
2018-05-15 10:15:32 +03:00
Markus Mäkelä
00581e7f35
MXS-1826: Fix COM_CHANGE_USER regression
The re-authentication done in MaxScale caused multiple error packets to be
sent for the same COM_CHANGE_USER. In addition to this, the failure of
authentication did not terminate the client connection.

The change in behavior requires the test case to be changed as well.
2018-05-15 10:14:38 +03:00
Markus Mäkelä
75eded4b89
Merge branch '2.2' into develop 2018-05-14 11:24:09 +03:00
Markus Mäkelä
ec4569497e
Merge branch '2.1' into 2.2 2018-05-14 10:14:16 +03:00
Markus Mäkelä
b6eff12334
Merge branch '2.2' into develop 2018-05-07 09:57:47 +03:00
Markus Mäkelä
689c02d301
Send error on reauthentication failure
When the reauthentication of a client fails, the correct error should be
sent.
2018-05-07 09:57:09 +03:00
Markus Mäkelä
658329b648
Merge branch '2.2' into develop 2018-05-03 10:00:44 +03:00
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
Johan Wikman
b36f6faa7e MXS-1754 Reintroduce maxscale::Worker
Worker is now the base class of all workers. It has a message
queue and can be run in a thread of its own, or in the calling
thread. Worker can not be used as such, but a concrete worker
class must be derived from it. Currently there is only one
concrete class RoutingWorker.

There is some overlapping in functionality between Worker and
RoutingWorker, as there is e.g. a need for broadcasting a
message to all routing workers, but not to other workers.

Currently other workers can not be created as the array for
holding the pointers to the workers is exactly as large as
there will be RoutingWorkers. That will be changed so that
the maximum number of threads is hardwired to some ridiculous
value such as 128. That's the first step in the path towards
a situation where the number of worker threads can be changed
at runtime.
2018-04-16 14:53:08 +03:00
Markus Mäkelä
ec33fcf87d
Merge branch '2.2' into develop 2018-04-13 14:53:00 +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
Markus Mäkelä
e76b00e340
Merge branch '2.2' into develop 2018-04-10 15:28:00 +03:00
Markus Mäkelä
d28cf6b948
Merge branch '2.1' into 2.2 2018-04-10 15:27:20 +03:00
Markus Mäkelä
304499bd36
Merge branch '2.2' into develop 2018-04-10 14:05:39 +03:00
Markus Mäkelä
fad4508fe2
Merge branch '2.1' into 2.2 2018-04-10 13:49:42 +03:00
Markus Mäkelä
1e3ab1fc7c
MXS-1765: Update current command for KILL processing
The current command needs to be updated before the queries are actually
routed. This allows the KILL command detection and processing to correctly
work.
2018-04-10 13:45:47 +03:00
Johan Wikman
6535448374 Merge branch '2.2' into develop 2018-03-27 10:17:15 +03:00
Johan Wikman
3d45d452eb MXS-1734 Add possibility to instruct when to dump statements
With the configuration entry

dump_last_statements=[never|on_close|on_error]

you can now specify when and if to dump the last statements
of of a session.
2018-03-27 09:35:35 +03:00
Johan Wikman
6d599395d4 MXS-1734 Add statement dumping mechanism
With the configuration entry

   retain_last_statements=<unsigned>

or the debug flag '--debug=retain-last-statements=<unsigned>',
MaxScale will store the specified number of last statements
for each session. By calling

    session_dump_statements(session);

MaxScale will dump the last statements as NOTICE messages.
For debugging purposes.
2018-03-27 09:35:35 +03:00
Markus Mäkelä
04ca9658c5
Use correct executable name
The test executable name had a typo in it.
2018-03-20 13:11:52 +02:00
Johan Wikman
34dd8a52bb MXS-1475 Allow the setting on N vars with one stmt
With this change, the following will be possible.

SET @maxscale.cache.populate=false, @maxscale.cache.use=true;
2018-03-16 14:34:04 +02:00
Johan Wikman
805e3578a2 MXS-1475 Address review issues
- Clean up session header.
- Add test case
2018-03-16 14:34:04 +02:00
Johan Wikman
2434482dc6 MXS-1475 Attempt to set unknown MXS user variable causes error
By causing an error if an unknown MaxScale user variable is set,
the user will become aware of typos etc.
2018-03-16 14:34:04 +02:00
Johan Wikman
872a51a376 MXS-1475 Enable MaxScale specific user variables
With the changes in this commit it is possible to add and remove
MaxScale specific user variables. A MaxScale specific user variable
is a user variable that is interpreted by MaxScale and that
potentially changes the behaviour of MaxScale.

MaxScale specific user variables are of the format "@maxscale.x.y"
where "@maxscale" is a mandatory prefix, x a scope identifying the
component that handles the variable and y the component specific
variable. So, a variable might be called e.g. "@maxscale.cache.enabled".
The scope "core" is reserved (although not enforced yet) to MaxScale
itself.

The idea is that although MaxScale catches these, they are passed
through to the server. The benefit of this is that we do not need to
detect e.g. "SELECT @maxscale.cache.enabled", but can let the result
be returned from the server.

The interpretation of a provided value is handled by the component that
adds the variable. In a subsequent commit, it will be possible for a
component to reject a value, which will then cause an error to be
returned to the client.

There are 3 new functions:

- session_add_variable() using which a variable is added,
- session_remove_variable() using which a variable is removed, and
- session_set_variable_value().

The two former ones are to be called by components, the last one by
the protocol that catches the "set @maxscale..." statements.
2018-03-16 14:34:04 +02:00
Johan Wikman
5dfa0c1226 MXS-1475 Take SetParser and SqlModeParser into use
These changes are the first in the route toward supporting
MaxScale specific variables such as

    set @MAXSCALE.CACHE.ENABLED=TRUE
2018-03-16 14:34:04 +02:00
Johan Wikman
676594b8dd MXS-1475 Update test to use new classes
Test now implemented in terms of SetParser and SqlModeParser.
2018-03-16 14:34:04 +02:00
Johan Wikman
23d1dd42de MXS-1475 Add sql_mode parser
Given the value in a statement like "SET SQL_MODE=..." this parser
is capable of deducing whether SQL_MODE is set to DEFAULT or ORACLE
or something else.
2018-03-16 14:34:04 +02:00
Johan Wikman
f11d60420d MXS-1475 Add SetParser custom parser
SetParser is capable of returning the exact variable and value
of a "SET X=Y" statement, in the cases where X is of a specific
set of variables; currently "SQL_MODE" and "@MAXSCALE...".

The actual value of the SET statement also needs to be parsed in
the case of SQL_MODE, but it becomes unnecessary convoluted if that
information somehow should conditionally be expressable in a return
value.

So, the value will be parsed separately.
2018-03-16 14:34:04 +02:00
Markus Mäkelä
771716e9db
Merge branch '2.2' into develop 2018-02-05 10:22:43 +02:00
Markus Mäkelä
8c8aaeae8e Prevent double closing of client DCB
If the client is closing the connection but routing the COM_QUIT fails,
the DCB would be closed twice.
2018-02-02 12:28:07 +02:00
Markus Mäkelä
9f0a691233 Always stop the session by closing the client DCB
By always starting the session shutdown process by stopping the client
DCB, the manipulation of the session state can be removed from the backend
protocol modules and replaced with a fake hangup event.

Delivering this event via the core allows the actual dcb_close call on the
client DCB to be done only when the client DCB is being handled by a
worker.
2018-02-02 12:28:07 +02:00
Markus Mäkelä
f53e112bf4 Don't write errors to dummy sessions
If a DCB is closed before a response to the handshake packet is received,
the DCB's session will point to the dummy session. In this case no error
should be written to the DCB.
2018-01-31 13:38:28 +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
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
Johan Wikman
f129dd56be MXS-1595 Rename mysqlclient to mariadbclient
Documentation update will follow.
2018-01-05 10:01:50 +02:00