2123 Commits

Author SHA1 Message Date
Markus Makela
dd9f7fbbb7 Fixed rwsplit length calculations for multi-statements
The calculations used the amount of bytes read instead of amount of bytes
available and also read one byte too much.
2016-03-04 09:56:18 +02:00
Markus Makela
d1837e0e4a Added more error logging and fixed parsing of packets in readwritesplit
Readwritesplit tried to parse COM_PING packets which only have one byte of
payload. This would cause the queries to fail to parsed.
2016-03-04 07:55:03 +02:00
Markus Makela
d3da98b58f Merge branch 'MXS-544' into develop-MXS-544-merge 2016-03-03 21:39:39 +02:00
Markus Makela
1a2bd8b234 Added FindLua.cmake from KitWare's repo for CMake 3.4.3
Some platforms did not have the FindLua.cmake file which caused errors on
configuration. Moved the invocation of find_package to the filter CMakeLists.txt
so that it is only called if the luafilter is built.
2016-03-03 16:42:48 +02:00
Markus Makela
76f06572ed Fix to multi-statement processing
Renamed is_mysql_comment_start to is_mysql_statement_end because it checks
whether a statement truly ends instead of just checking comment block starts.

The calculations for buffer length in readwritesplit now use the payload size
instead of the buffer size.
2016-03-03 10:44:11 +02:00
Markus Makela
8b6595aa68 Improvements and fixes to strchr_esc_mysql
The C style comments were not ignored and the -- style comments
did not check for the trailing whitespace and made return values char*.

The creation of a stored procedure would prevent sessions from using
any of the slave servers because readwritesplit would interpret
the creation statement as a multi-statement query.

Parts of modutil and readwritesplit now compare pointers to pointers instead of
converting pointers to integers.
2016-03-02 21:34:22 +02:00
Markus Makela
2589630b8e Unknown SQL commands are treated as writes
This will prevent any possible damage to a slave by new or unexpected commands.
2016-03-02 21:27:34 +02:00
Markus Makela
9bfef5c7c1 Improved multi-statement detection in readwritesplit
Now comment blocks and identifiers quoted with backticks are taken into
consideration when multi-statements are processed.
2016-03-02 21:27:34 +02:00
Markus Makela
e1a8a6f373 Luafilter is not built by default
The luafilter requires the lua development libraries so it isn't built
by default.
2016-03-02 13:37:00 +02:00
Markus Makela
b2742f02b9 More formatting of code
Code formatting.
2016-03-02 13:28:12 +02:00
Markus Makela
2204a245c9 General cleaning up of the luafilter
Renamed variables to make their use more clear and cmake now looks for the Lua
libraries.
2016-03-02 13:28:12 +02:00
Markus Makela
140d284eed Updated documentation for luafilter
Added more documentation to functions about how, when and with what parameters
the Lua functions are called with. Also adjusted the module version to experimental.
2016-03-02 13:27:24 +02:00
Markus Makela
1c74ca0ec7 Cleaned up the luafilter. 2016-03-02 13:27:24 +02:00
Markus Makela
3f3c553736 Finalized query blocking. 2016-03-02 13:26:50 +02:00
Markus Makela
5d0f3eb467 Added a simple test for Lua return values from fuction calls. If the Lua function returns a string, the current query is replaced with it. 2016-03-02 13:26:50 +02:00
Markus Makela
7e24d4c88b Added missing calls to the global script 2016-03-02 13:26:49 +02:00
Markus Makela
61ec8458d3 Initial implementation of a Lua filter 2016-03-02 13:26:49 +02:00
Markus Makela
2a2fdb2cc6 testing of Lua 2016-03-02 13:26:10 +02:00
Johan Wikman
1d4779215d Ensure symbols are resolved at link-time.
With the linker flags "-Wl,-z,defs", all symbols used by a library
are resolved at link-time. Otherwise they will be resolved at runtime.
The use of these flags ensures that missing symbols are found as
early as possible.

Case in point, the binlog router test-cases failed, because the loading
of the binlog router failed due to missing symbols my_uuid_init and
my_uuid. The reason was that when maxscale no longer was linked with
the embedded library, those symbols were not available.

Now we know that the loading of the binlog router will not fail due
to missing symbols.
2016-03-01 21:29:13 +02:00
Johan Wikman
9b5550c053 Link binlog router with embedded lib.
Binlog router uses my_uuid_init and my_uuid, which are non-public
functions available in the embedded library. Consequently, blr
must currently be linked with the embedded library.

A custom implementation of these functions should be provided, in
order to break that dependency.
2016-03-01 21:25:47 +02:00
Johan Wikman
9a0534d0f6 Use maxscale_uptime().
MaxScaleUptime() has been renamed to maxscale_uptime(). Take
prototype from include file.
2016-03-01 21:23:43 +02:00
Johan Wikman
cb3213af63 server/include/poll.h renamed to server/include/maxscale/poll.h
Due to an include conflict between /usr/include/poll.h and
maxscale/server/include/poll.h the latter was moved to
maxscale/server/include/maxscale/poll.h.

Once 1.4 is out, all maxscale header files will be moved to that
same sub-directory. That will prevent include conflicts and also
make it easy to see which include files belong to maxscale and
which do not.
2016-03-01 12:56:39 +02:00
Markus Makela
bf1a789376 Added configurable multistatement behavior
Whether all queries should be routed to the master after a multistatement
query is executed can now be controlled with the `strict_multi_stmt` option.

When the option is disabled queries executed after a multistatement query will
be routed normally.
2016-03-01 10:45:08 +02:00
Markus Makela
ac007fa8f5 MXS-497: Multi-statement queries are always routed to the master
This will prevent the routing of queries that modify data to the slaves.

In the future a more intricate solution can done where all the statements
are parsed and the destination is resolved based on the actual contents.
2016-03-01 09:32:55 +02:00
Markus Makela
b88d66357e Shard router is no longer built by default
The shardrouter module is not finished and should not be built for releases.
2016-02-29 17:18:20 +02:00
Markus Makela
1ebb998056 Fixed wrong DCB being used in gw_get_shared_session_auth_info
The caller DCB was used instead of the session client DCB. This caused
a crash when a backend DCB was getting the shared data since those DCBs
have a NULL data pointer.
2016-02-29 16:53:39 +02:00
Markus Makela
2990c3b25f Fixed wrong variable being freed in qlafilter
The match parameter was freed twice.
2016-02-29 16:17:55 +02:00
Markus Makela
bf24f18805 Merge branch 'develop' into MXS-544 2016-02-29 10:40:33 +02:00
Markus Makela
87ccff097d Minor fix to token processing of dbfwfilter
The yylineno was manually simulated even though it can be automated by enabling
the yylineno option.
2016-02-26 12:30:56 +02:00
Markus Makela
784166ad0b Added missing check for fopen return value
This would have led to a crash when a NULL pointer would have been used as
a valid FILE handle.
2016-02-25 20:10:37 +02:00
Markus Makela
2c28d8c5de Removed unused functions and variables from dbfwfilter
Removed the old parsing functions which are no longer used.
2016-02-25 20:09:10 +02:00
Markus Makela
7b8200eec0 Fixed build failures with older versions of Bison
Older versions of Bison don't include the yyparse function in the generated
header and use deprecated options.
2016-02-25 09:32:04 +02:00
Markus Makela
57af3e3e24 Added support for older Bison versions
The older versions of Bison use the deprecated versions of various options.
The automatic prefixing of tokens is not present in older versions so to
accommodate for this, all tokens were manually prefixed.
2016-02-25 09:32:04 +02:00
counterpoint
c26b5a3dd0 Tidy earlier fix and apply another - both follow the principle of not removing the link from session to client DCB when dcb_close is called for client DCB. The close will not fully complete, but will be finalised when the session is freed. At this time, no DCBs will be referring to the session. These measures protect the dcb->data in the client DCB from being lost until the session is no longer needed. 2016-02-24 15:34:02 +00:00
counterpoint
5122777829 Try to fix problem if balancing free client DCB and free session so that auth data is always available and client DCB is not freed until session is ready to be freed. Also fix problem in auth logic. 2016-02-24 10:00:45 +00:00
Markus Makela
cb2e3b898e Cleaned up qlafilter, topfilter and namedserverfilter instance creation
The change fixes a crash when no filebase parameter is given for the filter.

The instance creation functions of these filters had spossible memory leaks in
case errors in the configuration occurred. In addition to these, they would be
successfully created even if unexpected parameters were given.
2016-02-23 21:45:31 +02:00
Markus Makela
aec1310c52 MXS-580: Added more options for filters
The tee, qlafilter, namedserverfilter and topfilter now support the same filter
options: case, ignorecase and extended. The extended filter option enables
the Extended Regular Expression syntax for the filters which is used when
matching queries.
2016-02-23 20:52:53 +02:00
Markus Makela
19356be848 Updated documentation about Bison and Flex dependency
The dbfwfilter now requires Bison and Flex to be built
2016-02-23 20:52:52 +02:00
counterpoint
395cbdc103 Simplify handling of "client data" by having a pointer to it only in DCB and not in session structure. Change name of session->client to session->client_dcb for greater clarity. Temporary free of client data in DCB, to be moved to authenticator when it becomes a module. Fix incorrect name of listener_alloc. 2016-02-23 11:13:21 +00:00
Markus Makela
1adbe3b23a No user definitions in dbfwfilter rules is treated as an error again
The lack of user definition lines in the dbfwfilter rule file was ignored
previously but this change makes the lack of users an error again. Also
added function documentation to some of the functions.
2016-02-23 10:34:12 +02:00
counterpoint
ef8a20cceb Fix silly mistakes. 2016-02-22 11:16:51 +00:00
counterpoint
5077933e41 Fix bug in mysql_client.c (over optimisation of protocol setting); various clarifications and improvements re code review. 2016-02-22 11:05:02 +00:00
Markus Makela
28bd7c2202 Merge branch '1.2.1-binlog_router_trx' into develop 2016-02-19 18:51:59 +02:00
Markus Makela
a947b33769 MXS-585: Fixed buffer length instead of packet length being used in a calculation
The usage of the buffer length in the authentication success checks causes
the authentication to fail with routers that don't require statement input.
2016-02-18 18:03:21 +02:00
Markus Makela
c25ef2f72a Added missing 5.5.5- prefix to MaxScale MySQL version
The handshake was sending "MaxScale 1.3.0" as the server version which causes
some connectors to think that the version is not valid.
2016-02-18 18:03:21 +02:00
Markus Makela
effa2dbdae Set dbfwfilter maturity to GA and set the version to 1.1.0
The module has been GA for a while and it has also changed so the version
should be updated.
2016-02-17 10:59:26 +02:00
Markus Makela
497a72d42f Added extra logging to dbfwfilter output
The real username and host is now logged in addition to the user definition
that it matched. The messages also have the service name to distinct
connections to two different services which both use the same filter.
2016-02-17 10:45:21 +02:00
Markus Makela
59f5880898 Added missing OK byte to payload size calculation
The OK byte was not taken into notice when the total size of all the payloads
in all the packets was calculated.
2016-02-17 08:30:50 +02:00
Markus Makela
63ce9fe6bc Fixed formatting and added more error checks
Added log messages when ftruncate fails and cleaned up formatting.
2016-02-16 13:06:25 +02:00
Markus Makela
cd2af6ffef Cleaned up the code based on the code review
Added missing error condition checks and cleaned up code.
2016-02-16 13:06:25 +02:00