Skip to content

Commit 360e06f

Browse files
author
Astha Pareek
committed
BUG#17920923 - BACKPORT PATCH FOR BUG#14511533 INTO 5.6
Problem: Server crash was observed when code first checked if semisync was enabled without lock, if so it takes the lock and checks again. If semisync gets disabled in-between the first and second check, an assert incorrectly referenced a null pointer for active transaction which leads to the crash. Solution: The assert is relocated onto a position where active_tranxs buffer is valid.
1 parent 74901f0 commit 360e06f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

plugin/semisync/semisync_master.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818

1919
#include "semisync_master.h"
20+
#if defined(ENABLED_DEBUG_SYNC)
21+
#include "debug_sync.h"
22+
#include "sql_class.h"
23+
#endif
2024

2125
#define TIME_THOUSAND 1000
2226
#define TIME_MILLION 1000000
@@ -623,7 +627,11 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
623627
PSI_stage_info old_stage;
624628

625629
set_timespec(start_ts, 0);
626-
630+
#if defined(ENABLED_DEBUG_SYNC)
631+
/* debug sync may not be initialized for a master */
632+
if (current_thd->debug_sync_control)
633+
DEBUG_SYNC(current_thd, "rpl_semisync_master_commit_trx_before_lock");
634+
#endif
627635
/* Acquire the mutex. */
628636
lock();
629637

@@ -762,15 +770,14 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
762770
}
763771
}
764772

765-
l_end:
766773
/*
767774
At this point, the binlog file and position of this transaction
768775
must have been removed from ActiveTranx.
769776
*/
770777
assert(!getMasterEnabled() ||
771778
!active_tranxs_->is_tranx_end_pos(trx_wait_binlog_name,
772779
trx_wait_binlog_pos));
773-
780+
l_end:
774781
/* Update the status counter. */
775782
if (is_on())
776783
rpl_semi_sync_master_yes_transactions++;

0 commit comments

Comments
 (0)