diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-10-20 20:13:45 -0600 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2022-01-05 13:41:58 -0700 |
commit | 515dc593ab47371875434e1de0f77125ce3dc6f4 (patch) | |
tree | 4daf7500ca090923ceab6d72a5b5e591e58e7851 /sql/sql_class.h | |
parent | c18896f9c1ce6e4b9a8519a2d5155698d82ae45a (diff) | |
download | mariadb-git-bb-10.4-MDEV-11853.tar.gz |
MDEV-11853: semisync thread can be killed after sync binlog but before ACK in the sync statebb-10.4-MDEV-11853
Problem:
========
If a primary is shutdown during an active semi-sync connection
during the period when the primary is awaiting an ACK, the primary
hard kills the active communication thread and does not ensure the
transaction was received by a replica. This can lead to an
inconsistent replication state.
Solution:
========
During shutdown, the primary should wait for an ACK or timeout
before hard killing a thread which is awaiting a communication. We
extend the `SHUTDOWN WAIT FOR SLAVES` logic to identify and ignore
any threads waiting for a semi-sync ACK in phase 1. Then, before
stopping the ack receiver thread, the shutdown is delayed until all
waiting semi-sync connections receive an ACK or time out. The
connections are then killed in phase 2.
Reviewed By:
============
TODO
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index b39be36a9dd..9608c07b45a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4826,12 +4826,31 @@ public: LOG_INFO *current_linfo; Slave_info *slave_info; + /* + Indicates if this thread is suspended due to awaiting an ACK from a + replica. True if suspended, false otherwise. + */ + bool awaiting_semisync_ack; + void set_current_linfo(LOG_INFO *linfo); void reset_current_linfo() { set_current_linfo(0); } + void set_awaiting_semisync_ack(bool status) + { + mysql_mutex_assert_owner(&LOCK_thd_data); + awaiting_semisync_ack= status; + } + int register_slave(uchar *packet, size_t packet_length); void unregister_slave(); bool is_binlog_dump_thread(); + bool is_awaiting_semisync_ack() + { + mysql_mutex_lock(&LOCK_thd_data); + bool res= awaiting_semisync_ack; + mysql_mutex_unlock(&LOCK_thd_data); + return res; + } #endif inline ulong wsrep_binlog_format() const |