Skip to content

Commit 2f47ddb

Browse files
Fix self-abort of SR transactions
It's more correct and also allows to properly pass 0 seqno instead of undefined (-1).
1 parent a6b78f7 commit 2f47ddb

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

sql/service_wsrep.cc

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,21 @@ extern "C" void wsrep_handle_SR_rollback(THD *bf_thd,
201201
victim_thd->wsrep_sr().fragments_certified(),
202202
wsrep_thd_transaction_state_str(victim_thd));
203203

204-
/* Note: do not store/reset globals before wsrep_bf_abort() call
205-
to avoid losing BF thd context. */
206-
if (!(bf_thd && bf_thd != victim_thd))
204+
const bool self_abort= (!bf_thd || bf_thd == victim_thd);
205+
if (self_abort)
207206
{
207+
/* Don't hold the lock in sync wait. wsrep_thd_self_abort() grabs
208+
the same lock again before performing BF abort. */
209+
wsrep_thd_UNLOCK(victim_thd);
208210
DEBUG_SYNC(victim_thd, "wsrep_before_SR_rollback");
209-
}
210-
if (bf_thd)
211-
{
212-
wsrep_bf_abort(bf_thd, victim_thd);
213-
}
214-
else
215-
{
216211
wsrep_thd_self_abort(victim_thd);
217212
}
218-
219-
wsrep_thd_UNLOCK(victim_thd);
220-
221-
if (bf_thd)
213+
else
222214
{
215+
/* Note: do not store/reset globals before wsrep_bf_abort() call
216+
to avoid losing BF thd context. */
217+
wsrep_bf_abort(bf_thd, victim_thd);
218+
wsrep_thd_UNLOCK(victim_thd);
223219
wsrep_store_threadvars(bf_thd);
224220
}
225221
}

0 commit comments

Comments
 (0)