1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-18450 Slaves wait shutdown

The patches features an optional shutdown behavior to hold on until
after all connected slaves have been sent the last binlogged event.
The connected slave is one whose START SLAVE has been acknowledged and
that was not stopped since that though it could be technically
reconnecting in background.

The solution therefore disallows killing the dump thread until is has
found EOF of the latest binlog file.  It is up to the shutdown
requester (DBA) to set up a sufficiently large shutdown timeout value
for shudown to wait patiently until lagging behind slaves have been
synchronized. On the other hand if a specific slave needs exclusion
from synchronization the DBA would have to stop it manually which
would terminate its dump thread.

`mysqladmin shutdown' is extended with a `--wait_for_all_slaves' option
which translates to `SHUTDOW WAIT FOR ALL SLAVES' sql query
to enable the feature on the client side.

The patch also performs a small refactoring of the server shutdown
around close_connections() to introduce kill thread phases which
are two as of current.
This commit is contained in:
Sergey Vojtovich
2019-03-07 08:12:26 +04:00
committed by Andrei Elkin
parent e450527938
commit 3568427d11
19 changed files with 459 additions and 54 deletions

View File

@ -3194,12 +3194,6 @@ public:
/** number of name_const() substitutions, see sp_head.cc:subst_spvars() */
uint query_name_consts;
/*
If we do a purge of binary logs, log index info of the threads
that are currently reading it needs to be adjusted. To do that
each thread that is using LOG_INFO needs to adjust the pointer to it
*/
LOG_INFO* current_linfo;
NET* slave_net; // network connection from slave -> m.
/*
@ -4813,10 +4807,20 @@ private:
public:
#ifdef HAVE_REPLICATION
/*
If we do a purge of binary logs, log index info of the threads
that are currently reading it needs to be adjusted. To do that
each thread that is using LOG_INFO needs to adjust the pointer to it
*/
LOG_INFO *current_linfo;
Slave_info *slave_info;
void set_current_linfo(LOG_INFO *linfo);
void reset_current_linfo() { set_current_linfo(0); }
int register_slave(uchar *packet, size_t packet_length);
void unregister_slave();
bool is_binlog_dump_thread();
#endif
inline ulong wsrep_binlog_format() const
@ -4975,18 +4979,6 @@ public:
(THD_TRANS::DID_WAIT | THD_TRANS::CREATED_TEMP_TABLE |
THD_TRANS::DROPPED_TEMP_TABLE | THD_TRANS::DID_DDL));
}
/*
Reset current_linfo
Setting current_linfo to 0 needs to be done with LOCK_thd_data to
ensure that adjust_linfo_offsets doesn't use a structure that may
be deleted.
*/
inline void reset_current_linfo()
{
mysql_mutex_lock(&LOCK_thd_data);
current_linfo= 0;
mysql_mutex_unlock(&LOCK_thd_data);
}
uint get_net_wait_timeout()