Commit Graph

6516 Commits

Author SHA1 Message Date
14e399dd68 Move RWSplitSession into rwsplitsession.cc
Moved the class method definitions into the correct file.
2018-04-03 13:30:55 +03:00
d5643bc14d Create RWBackends from servers
Added a helper function that creates a list of servers to use. This should
remove some of the duplicate code in the routers.
2018-04-03 13:30:55 +03:00
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
8206e1f46d Move RWBackend::reply_is_complete into rwsplitsession.cc
The function is now defined in the correct file. Removed the debug output
as it can be logged inside RWBackend::set_reply_state.
2018-04-03 13:30:54 +03:00
8222bdbc20 Move reply_is_complete into RWBackend
Moved the reply state checking inside the RWBackend class to make it
possibly reusable in other parts of MaxScale. Also removed a redundant
function.
2018-04-03 13:30:54 +03:00
3857912c61 MXS-1503: Abort connection when inside transaction
Before the transaction migration is implemented, the connection must be
closed if a transaction is open and the connection to the master is
lost. Doing this retains the same transactionality as a direct connection
to the server would.
2018-04-03 13:30:54 +03:00
7f0745e552 MXS-1503: Queue command if executing a session command
When a non-connected target is chosed as the target server and the session
command history is not empty, the query needs to be placed into the query
queue and routed only after the session commands have been executed.
2018-04-03 13:30:53 +03:00
e57ac4b0a3 MXS-1502: Prune session commands
The session command history is now compacted to contain only the first and
last execution of a session command. This should still allow most of the
more eccentric use-cases of user variables while keeping the session
command history smaller.

Added some convenience functions into the SessionCommand class to make the
pruning process easier.
2018-04-03 13:30:53 +03:00
ce853d3f7f MXS-1503: Enable limited session command history
Enabling the session command history but limiting it to a history of 50
commands allows reconnections for sessions that don't change the state too
often.

As pooled connections will exceed this limit quite fast, they are not able
to reconnect to servers once connections are lost. To solve this problem,
the session command history needs a compaction process that removes
redundant history.
2018-04-03 13:30:53 +03:00
7e4665b03b MXS-1503: Respect max_slave_connections
The slave selection now again respects max_slave_connections. This means
that the amount of slave connections each session has will never grow
beyond the configured value.
2018-04-03 13:30:52 +03:00
4cf9bec10b MXS-1503: Restore slave reconnection
The slave connections can now be recovered after a failure as long as the
session command history is enabled. In comparison to the old
functionality, the server now replaces the connection when a query is
received instead of reconnecting when the slave fails.

As a negative side effect of this change, the max_slave_connections is no
longer enforced after the connection is created. To fix this broken
functionality, the connected slaves need to be preferred over unconnected
ones. This will be added in a follow-up commit.
2018-04-03 13:30:52 +03:00
3d63d18bdd MXS-1503: Split get_target_backend into smaller pieces
Split the code into separate functions. This should make it easier to
comprehend.
2018-04-03 13:30:52 +03:00
9c7578272c MXS-1503: Refactor slave selection
Refactored and cleaned up the slave selection in preparation of
reconnection code unification.
2018-04-03 13:30:52 +03:00
876187b340 MXS-1503: Enable master reconnection
The `master_reconnection` parameter now controls both the reconnection of
the master server as well as the migration of the master server to another
server. Although these two cases appear to be different, the end result
from readwritesplit's point of view is the same and are thus controlled
with the same parameter.

The RWBackend class now resets its internal state when it is closed. This
allows readwritesplit to handle the case when a result was expected from
the master but the master died before the result was returned. The same
code should also handle slave connection failures mid-result, allowing
Backend reuse.

Added a test case that verifies the new functionality when combined with
`master_failure_mode=error_on_write`.
2018-04-03 13:30:51 +03:00
481db8acbc MXS-359: Rename parameter to master_reconnection
Changing the parameter name to `master_reconnection` allows similar
reconnection functionality to be combined under one parameter.
2018-04-03 13:30:51 +03:00
3f803ab3e8 MXS-1503: Don't use empty smart pointers
The check for the existence of a valid pointer is now done in the correct
place.
2018-04-03 13:30:51 +03:00
be2186c8f1 MXS-1503: Remove redundant code
Moved session command execution into the Backend class itself as the
session commands are defined as a related part of it. This allows all
connections to execute session commands if some are available.

Removed explicit SERVER_REF usage in the readwritesplit connection
creation code and replaced it with SRWBackend. This allows the removal of
the get_root_master_backend function which duplicated the functionality in
get_root_master.
2018-04-03 13:30:51 +03:00
a1b5fcd4ff MXS-1503: Clean up connection creation function
The select_connect_backend_servers function is the main connection
creation function. Cleaned it up and split it into smaller, reusable
parts.
2018-04-03 13:30:51 +03:00
a0a37bf793 MXS-1503: Disable reconnection in clientReply
Disabled the reconnection in clientReply prior to moving the connection
creation code into routeQuery. This allows new connections to be made when
they are needed.
2018-04-03 13:30:50 +03:00
9f256f50eb Merge branch '2.2' into develop 2018-04-03 11:01:06 +03:00
f743e99795 Set internal DCB to NULL on close
The Backend::dcb() method gives the raw pointer to the internal DCB. This
pointer is used by at least readwritesplit to map raw DCB pointers to
backends. To prevent stale pointers from being returned, m_dcb needs to be
set to NULL after it has been closed.
2018-04-03 10:59:55 +03:00
4167e88719 MXS-1751: Fix crash with available_when_donor=true
The `MYSQL_ROW row` variable was being overwritten by the extra query done
by the SST method detection code. Moving it into its own function prevents
this and makes the code significantly easier to comprehend.

Added a test case that reproduced the problem (MaxScale crashed) and
verifies that the patch fixes the problem.
2018-03-31 20:21:07 +03:00
1ddcb15547 MXS-1625 Move RWS specific data out from function
In order to be able to move routing decision into the
query classifier, no RWS specific data can be present.
2018-03-29 13:02:38 +03:00
923de851f9 MXS-1703 Move more functions to MariaDBServer
Also, the QueryResult integer reading method now only reads non-negative integers
since the server rarely returns negative values. This frees negative values for
indicating parsing error(s).

Gtid-class was moved back to utility.hh/.cc because the QueryResult-class requires it.
2018-03-28 13:47:07 +03:00
f7ea12b8e4 Merge branch '2.2' into develop 2018-03-28 13:24:54 +03:00
93cd4e7de3 MXS-1625 Remove rwsplit_tmp_table_multi.cc
Contains no functionality anymore.
2018-03-28 12:43:07 +03:00
7209080236 MXS-1747 Improve error messages of rejoin operations
Now states which query caused the error.
2018-03-28 12:39:10 +03:00
6c32c7421b MXS-1746 Query global gtid_domain_id instead of session-specific value
The monitor queried the session-specific domain id, which does not follow the global
value while the session is alive. This caused the monitor to follow the wrong gtid
domain if the domain was changed after MaxScale was started. This patch modifies the
query to read the global value instead. Even this is not fool-proof, as existing
sessions can issue writes with the old domain, confusing the gtid-parsing.
2018-03-28 12:23:57 +03:00
46ebf19223 Fix luafilter build failure
The pointer passed to was of the wrong type.
2018-03-27 21:49:35 +03:00
0e968c2b28 MXS-1625 All RouteInfo functionality moved to routeinfo.cc
Provides a clearer separation between what deals with query
classification and what deals with query routing.

Functions have only been moved. No other cleanup has been
done.
2018-03-27 16:08:18 +03:00
279fbf0fbe Fix crash in monitor diagnostics
A const_cast was missing, causing an endless loop.
2018-03-27 13:29:20 +03:00
1d5128fc5b MXS-1703 Move do_show_slave_status() to MariaDBServer
Also took into use the QueryResult helper class.
2018-03-27 12:43:36 +03:00
6535448374 Merge branch '2.2' into develop 2018-03-27 10:17:15 +03:00
4b282920ae MXS-1734 Remove command line flag retain-last-statements
From a practical perspective it makes no relevant difference
whether you have to add an entry to the config file and restart
maxscale or if you have to restart maxscale and provide a specific
command line, so better to provide just either possiblity.

More important would be to provide a way for turning this feature
on and off at runtime.
2018-03-27 09:35:35 +03:00
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
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
cbbfb1c5c0 Merge branch '2.2' into develop 2018-03-27 07:25:32 +03:00
6e859fcf02 Merge branch '2.1' into 2.2 2018-03-27 07:25:00 +03:00
32bfcc117b MXS-1731: Ignore empty values in persisted configs
If a MaxScale-generated configuration defines an empty value, it is
ignored with the assumption that the next modification will cause the
problem to correct itself.
2018-03-27 07:24:29 +03:00
933a74a418 MXS-1739: Disable TLS session cache
Disabling the session cache prevents errors from being generated as the
default OpenSSL configuration is to enable session caching but with an
uninitialized context ID. In addition to preventing the errors, it
prevents the possible security problems implicated by the definition a
"static" context ID.
2018-03-27 07:23:46 +03:00
a4a5641f5b MXS-1703 Add convenience function + class for querying and storing results
An object of the class is returned as an auto_ptr to simplify memory management.
2018-03-26 15:43:54 +03:00
3b26db8e01 MXS-1725 Update luafilter to use session_set_response 2018-03-26 12:17:36 +03:00
e631f64458 MXS-1725 Update DbFWFilter to use session_set_response 2018-03-26 12:17:36 +03:00
c08fe079bf MXS-1725 Use session_set_response() in Cache
- session_set_response() made const correct
- set_response() function added to mxs::FilterSession; calls
  session_set_response().
- Cache uses set_response() for delivering the cache result
  to the client.
2018-03-26 12:17:36 +03:00
9fd64cf7ba MXS-1725 Provide mech. for short-circuiting req. processing
Filter that terminate the response processing now have a mechanism
using which a response can be provided in such a way that previous
filters will see the response.
2018-03-26 12:17:36 +03:00
81708e0ba2 MXS-1725 Replace macros with function
The macros MXS_SESSION_ROUTE_QUERY and MXS_SESSION_ROUTE_REPLY
are now defined in terms of functions that do the actual stuff.

Incidentally, the function session_route_reply() existed already
but was not used. Now slightly rewritten so that it does not simply
ignore misuse.
2018-03-26 12:17:36 +03:00
33457c7334 Merge branch '2.2' into develop 2018-03-26 10:07:17 +03:00
2bdac88b0b MXS-1738 Copy AF_UNIX data from listener to client dcb
We need to copy some data from a AF_UNIX based listener dcb
to the accepted client dcb, to prevent assertion violation in
dcb_get_port(). Further, to be able to log the path in the case
of an authentication error we need to copy that as well.
2018-03-26 10:06:42 +03:00
cf547b9532 Merge branch '2.2' into develop 2018-03-26 10:03:20 +03:00
033ef59c01 MXS-1733 Match empty values
If a table/database rule has been provided then if the resultset
does not contain table/database names, then we consider it a match
(subject to the column obviously).

Otherwise a rule like

        {
            "replace": {
                "table": "info",
                "column": "email"
            },
            "with": {
                "fill": "*"
            }
        }

could be bypassed with a statement like

    SELECT * FROM info UNION SELECT * from info

as the resultset in that case will not indicate that the column emain
is from info, which it will if the statement is

    SELECT * FROM info;
2018-03-26 10:02:57 +03:00