From a9cda4419becd34e956b1657d2cc5a07644c96bf Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 13 Nov 2015 23:43:11 +0200 Subject: [PATCH] MDEV-8066 Crash on unloading semisync_master plugin Bug was that ReplSemiSyncMaster::commitTrx() was waiting on a condition for state to change, but didn't take into account that one could have disabled semi-sync during the wait. --- plugin/semisync/semisync_master.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index bb9eb96f6d7..af5eb9d090d 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -477,6 +477,7 @@ void ReplSemiSyncMaster::add_slave() void ReplSemiSyncMaster::remove_slave() { lock(); + assert(rpl_semi_sync_master_clients > 0); rpl_semi_sync_master_clients--; /* Only switch off if semi-sync is enabled and is on */ @@ -744,8 +745,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, /* At this point, the binlog file and position of this transaction must have been removed from ActiveTranx. + active_tranxs_ may be NULL if someone disabled semi sync during + cond_timewait() */ - assert(thd_killed(NULL) || + assert(thd_killed(NULL) || !active_tranxs_ || !active_tranxs_->is_tranx_end_pos(trx_wait_binlog_name, trx_wait_binlog_pos));