5691 Commits

Author SHA1 Message Date
Johan Wikman
80815e0f54 Change session_link_dcb to void
The function attempted to detect use of freed memory, which is a
futile excersize.
2017-09-07 15:04:35 +03:00
Johan Wikman
44db97215f Deliver fake events for the current dcb immediately
If a fake event is added to the current dcb, we arrange things so
that it is delivered immediately when the handling of the event(s)
during which the fake event was added, has been performed.

Otherwise the event is delivered via the event loop.
2017-09-07 13:48:07 +03:00
Markus Mäkelä
e0c2af45c7 Handle AuthSwitchRequest responses to COM_CHANGE_USER
The COM_CHANGE_USER that is sent as a part of the reset process for a
persistent connection did not expect a AuthSwitchRequest packet to be sent
as that implies that the server did not take the authentication fast
path. In this case, an error message needs to be logged stating that the
server requested a different authentication plugin than was expected.
2017-09-07 09:51:23 +03:00
Johan Wikman
6794ed907a session_len must be included in assert 2017-09-06 16:41:56 +03:00
MassimilianoPinto
c239477630 MXS-1387: checking slave connection in COM_BINLOG_DUMP phase
MXS-1387: checking slave connection in COM_BINLOG_DUMP phase
2017-09-06 15:09:50 +02:00
Johan Wikman
699b3909f7 Set current_dcb to NULL if the current DCB is deleted 2017-09-06 13:45:39 +03:00
Markus Mäkelä
c542010e67 Fix internal test failures
The adminusers test did not properly initialize all subsystems in
MaxScale. The polling and DCB tests weren't updated with the changes to
the DCB closing.
2017-09-06 13:20:28 +03:00
MassimilianoPinto
795722506b MXS-1387: check if MariaDB 10 Slave has GTID request set.
MXS-1387: check if the connecting MariaDB 10 Slave has the GTID request
set and return error code which stops replication.
2017-09-06 11:13:15 +02:00
Johan Wikman
3770b4da95 Name read/fake queue consistently
Now dcb_readqueue and dvb_fakequeue are named readq and fakeq
respectively, to be consistent with the naming of the write
and delay queue.
2017-09-06 11:30:24 +03:00
Johan Wikman
84300c6d97 Do not manipulate read queue directly
Protocol modules should not manupulate the read queue directly,
but always access it via the functions created for that purpose.
2017-09-06 11:21:47 +03:00
Johan Wikman
24044a7376 Add dcb functions
dcb_readq_append()
dcb_readq_prepend()
dcb_readq_set()
dcb_readq_has()
dcb_readq_release()
dcb_readq_get()
dcb_readq_length()

No code but for DCB code itself should directly manipulate the
internals of a DCB. Thesse functions will be taken into use in
protocol modules.
2017-09-06 11:12:32 +03:00
Johan Wikman
186ee31abf Fix setting of this_thread.current_dcb
Also in the case of fake events, the current dcb must be set.
2017-09-05 16:04:59 +03:00
Johan Wikman
d3f4723c81 Do not report events for closed dcb
Before each event handler is called, it is checked whether the
dcb has been closed. If it has been, then the event handler is
not called.

The check has to be made before each event handler, because any
event handler can close the dcb.
2017-09-05 13:20:22 +03:00
Markus Mäkelä
d931787e2e Use _exit when daemonizing the process
The original process should use _exit if the forking of the child process
is successful. This makes sure that the exit handlers are called only when
the daemon process exits.
2017-09-04 17:56:34 +03:00
Markus Mäkelä
642232e26b Fix COM_CHANGE_USER unknown response handling
The response handling logic did not always take the last packet for
inspection when a COM_CHANGE_USER was executed. The OK packet will always
be the last one since the COM_CHANGE_USER is the last command that was
sent.
2017-09-04 17:45:30 +03:00
MassimilianoPinto
ff94a39038 Binlog server: fix closing slave connections called by MySQL admin connection
Binlog server: fix closing slave connections called by MySQL admin
connection
2017-09-04 15:23:24 +02:00
MassimilianoPinto
4c5f0d184c Binlog server: force fake Client DCB close in errorReply
Binlog server: force fake Client DCB close in errorReply. This fixes an
issue when START SLAVE, with new config, is called after a previous one
with errors.
2017-09-04 15:23:24 +02:00
Johan Wikman
2da7a93473 Destroy workers after services
The workers need to be destroyed only after services have been
to ensure that they are around in case the destruction of services
involves the closing of dcbs.
2017-09-04 16:01:42 +03:00
Johan Wikman
2f0292fd68 Relax dcb_close assert
If the current worker id is -1, we do not insist that the dcb
is closed by the owning thread. That will happen only for dcbs
that are created before the workers have been started and hence
it is also ok to close them after the workers have exited.
2017-09-04 16:00:27 +03:00
Johan Wikman
b43ab674e3 Add dcb_close_in_owning_thread(DCB*);
Allows a DCB to be closed by a thread other than the owning
thread.
2017-09-04 13:41:16 +03:00
Johan Wikman
ccbff0f6d4 Allow debugging of dcb event handling
Using DCB_LOG_EVENT_HANDLING is defined, a notice will be
logged for each event when it is handled.
2017-09-04 11:29:18 +03:00
Johan Wikman
1a468049b8 Overwrite dcb thread id at final close 2017-09-04 11:09:48 +03:00
Markus Mäkelä
862548666b MXS-1367: Enable MYSQL_OPT_RECONNECT for internal connections
The automatic reconnection feature of the Connector-C was not
enabled. Enabling it should reduce the amount of false positives that the
monitors pick up.
2017-09-04 09:19:20 +03:00
Markus Mäkelä
f9c5578bdd MXS-1384: Remove parameter length limitations
There is no reason to limit configuration parameter names or values to 256
characters.
2017-09-01 22:02:33 +03:00
Markus Mäkelä
d7662a10af MXS-1385: Fix truncation of script variables
The replacement of script variables now uses the maximum string length of
the original and replacement to make sure there's enough buffer space.
2017-09-01 21:51:15 +03:00
MassimilianoPinto
0a1608d90d Log proper message in errorReply when master state is BLRM_SLAVE_STOPPED
Log proper message in errorReply when master state is BLRM_SLAVE_STOPPED
2017-09-01 16:48:20 +02:00
MassimilianoPinto
85f395394b Connection retry limit minor changes
Connection retry limit minor changes
2017-09-01 13:52:40 +02:00
Johan Wikman
d0ec6e3762 MXS-1378 Log session id
If the session id is known, it will be logged together with all
messages. If present, the session id appears, enclosed in paranthesis,
right after the message category. E.g.

    2017-08-30 12:20:49   warning: (4711) [masking] The rule ...
2017-09-01 13:22:06 +03:00
Johan Wikman
61a2c960ec MXS-1378 Provide access to current session
Provide access to current session and session id. This will
be used by the logging mechanism for logging the session id
together with messages.
2017-09-01 13:20:20 +03:00
Johan Wikman
eff5e7431a MXS-1378 Provide access to the current DCB in 2.1
Conceptually this is a cherry-pick of commit
67efd1daeabbc398b8a8fbc0cd02c2af26e4cb6c (2.2), but too much has
changed to actually be able to cherry-pick that commit.
2017-09-01 13:20:20 +03:00
MassimilianoPinto
9230420872 The blr_master_close() is now called in the main worker thread.
The blr_master_close() is now called in the main worker thread by:
blr_stop_slave() and blr_stop_start_master()
2017-09-01 11:49:27 +02:00
Markus Mäkelä
22ceac6676 Update alter server help text
Added `persistpoolmax` and `persistmaxtime` to the help output of `show
servers`.
2017-09-01 12:06:44 +03:00
Markus Mäkelä
7cef722282 Handle unexpected responses to COM_CHANGE_USER
When an unexpected response to a COM_CHANGE_USER is received, it is now
processes and discarded instead of treated as an error. This will allow
further analysis of the situation in addition to possibly solving some of
the problems that the persistent connections have.

Added extra info level logging to relevant parts of the code that deal
with the COM_CHANGE_USER reply processing. This information should allow
tracking of the response state for debugging purposes.
2017-09-01 11:28:21 +03:00
Markus Mäkelä
63c803a818 MXS-1379: Route conflicting queries to current shard
All conflicting queries are routed to the shard which contains the
currently active database.
2017-09-01 11:28:21 +03:00
Johan Wikman
18cb61f7de Delay closing in dcb_close
If a dcb being closed is the dcb for which events are currently being
processed, the dcb is not closed immediately but only after all events
have been delivered.
2017-09-01 11:03:23 +03:00
MassimilianoPinto
cfe06a563e Remove saving/updating GTID repo when maxscale starts
Remove saving/updating GTID repo when maxscale starts.
The repo update slows down the maxscale startup.
The saving was added in order populate GTID repo with current file but
it costs extra time to event validation routine when current binlog has
many events and it has a big size.
2017-08-31 17:27:52 +02:00
Johan Wikman
d7b04fc451 Add static storage to anonymous unit/thread structures
Without static, CentOS6 complains about non-local variable
using anonymous type.
2017-08-31 12:45:16 +03:00
MassimilianoPinto
e1efb91ea5 MXS-1156: MASTER_CONNECT_RETRY is a new option for CHANGE MASTER TO
MXS-1156: MASTER_CONNECT_RETRY is a new option for CHANGE MASTER TO.

The ‘connect_retry’, ‘master_retry_count’ options are now in use for
both service and
router_options.
2017-08-31 11:01:03 +02:00
MassimilianoPinto
42833386f5 MXS-1156: added configuration entry point for connection retry parameters.
MXS-1156: added configuration entry points for connection retry
parameters.

Variable names have been also changed.
2017-08-31 11:01:03 +02:00
MassimilianoPinto
c91187d4de MXS-1156: added limit to master connect retry
MXS-1156: added limit to master connect retry
2017-08-31 11:01:03 +02:00
MassimilianoPinto
3c7a0014a9 MXS-1156: Store master_heartbeat_period in master.ini
MXS-1156: Store master_heartbeat_period in master.ini
2017-08-31 11:01:03 +02:00
MassimilianoPinto
0f5f9f8228 MXS-1156: Disable heartbeat if value is set to 0
MXS-1156: Disable heartbeat if value is set to 0.

A warning log is written in maxscale log file when heartbeat is not set.
2017-08-31 11:01:03 +02:00
MassimilianoPinto
5b2cfac3cb MXS-1156: Added new option MASTER_HEARTBEAT_PERIOD to CHANGE MASTER TO
MXS-1156: Added new option MASTER_HEARTBEAT_PERIOD to CHANGE MASTER TO
2017-08-31 11:01:03 +02:00
Johan Wikman
68b7d88fa1 Check return value of freopen
Otherwise compilation fails in release mode.
2017-08-30 14:36:51 +03:00
Johan Wikman
63257f1b2a MXS-1378 Log session id
If the session id is known, it will be logged together with all
messages. If present, the session id appears, enclosed in paranthesis,
right after the message category. E.g.

    2017-08-30 12:20:49   warning: (4711) [masking] The rule ...
2017-08-30 13:58:42 +03:00
Johan Wikman
e7926d770e MXS-1378 Provide access to current session
Provide access to current session and session id. This will
be used by the logging mechanism for logging the session id
together with messages.
2017-08-30 13:58:42 +03:00
Johan Wikman
67efd1daea MXS-1378 Provide access to the current DCB
This will be used by a subsequent `session_get_current()` and
`session_get_current_id()` for obtaining the current SESSION and
session id, respectively. The latter of those will be used by the
logging mechanism for logging the session id in conjunction with
messages.
2017-08-30 13:58:42 +03:00
Markus Mäkelä
e6f78bfcb3 Pass modutil function state as a struct
This allows the type to change without changing it at the call sites.
2017-08-29 22:46:35 +03:00
Markus Mäkelä
c5581faae7 Always collect contiguous results for COM_CHANGE_USER
The response to the COM_CHANGE_USER should always be turned into a
contiguous buffer of complete packets. This guarantees that the code that
processes it functions properly.
2017-08-29 22:24:00 +03:00
Johan Wikman
2a346fd061 MXS-1376 Really close a DCB only at the end of event loop
When dcb_close() is called, the DCB is only marked for closing
and the actual closing takes place only after all event handlers
have been called. That way, the state of the DCB will not change
during event processing but only after.

From a handler perspective this should now be just like it was
when the zombie queue was present.

TODO: There are far too many state variables or variables akin to
      state variables - dcb_role, state, persistentstart, n_close -
      in DCB. A cleanup is warranted.
2017-08-29 15:44:50 +03:00