-
Venkatesh Duggirala authored
Problem: While some active transaction are waiting for ack from Slave, executing 'RESET MASTER' is leaving Master's semisync in bad state. Analysis: In ReplSemiSyncMaster::commitTrx, when transaction is waiting for an acknowledgement from the Slave, before it goes into the wait state, it increases rpl_semi_sync_master_wait_sessions status variable to indicate the number of sessions waiting for the acknowledgements. Also before it goes into the wait state, it releases LOCK_binlog_ lock to avoid any hang issues for the other sessions which are looking for LOCK_binlog_. When the thread releases LOCK_binlog_ lock and waiting for the acknowledgement, there is a possibility that some other thread which is executing 'RESET MASTER' can get the lock and reset all the status variables. rpl_semi_sync_master_wait_sessions is one of such status variables. After the wait is over in ReplSemiSyncMaster::commitTrx (either the timeout or received acknowledgement from Slave), the logic is decreasing rpl_semi_sync_master_wait_sessions) without checking whether 'RESET MASTER' was executing by any other parallel thread. This leads invalid value for rpl_semi_sync_master_wait_sessions status variable. Any other logic which is trying to use this status variable will lead to unexpected results in the server. Fix: Check the value of rpl_semi_sync_master_wait_sessions before decrementing it and decrement it only if it is non-zero value.
Venkatesh Duggirala authoredProblem: While some active transaction are waiting for ack from Slave, executing 'RESET MASTER' is leaving Master's semisync in bad state. Analysis: In ReplSemiSyncMaster::commitTrx, when transaction is waiting for an acknowledgement from the Slave, before it goes into the wait state, it increases rpl_semi_sync_master_wait_sessions status variable to indicate the number of sessions waiting for the acknowledgements. Also before it goes into the wait state, it releases LOCK_binlog_ lock to avoid any hang issues for the other sessions which are looking for LOCK_binlog_. When the thread releases LOCK_binlog_ lock and waiting for the acknowledgement, there is a possibility that some other thread which is executing 'RESET MASTER' can get the lock and reset all the status variables. rpl_semi_sync_master_wait_sessions is one of such status variables. After the wait is over in ReplSemiSyncMaster::commitTrx (either the timeout or received acknowledgement from Slave), the logic is decreasing rpl_semi_sync_master_wait_sessions) without checking whether 'RESET MASTER' was executing by any other parallel thread. This leads invalid value for rpl_semi_sync_master_wait_sessions status variable. Any other logic which is trying to use this status variable will lead to unexpected results in the server. Fix: Check the value of rpl_semi_sync_master_wait_sessions before decrementing it and decrement it only if it is non-zero value.
Loading