Skip to content

Commit e0271a7

Browse files
committed
MDEV-19408 Assertion on trx->state failed in ReadView::copy_trx_ids
ReadView::copy_trx_ids(): Relax a debug check. It failed to account for TRX_STATE_PREPARED_RECOVERED, which was introduced in MDEV-15772. It was also reading trx->state twice and failed to tolerate TRX_STATE_COMMITTED_IN_MEMORY, which could be concurrently assigned in lock_trx_release_locks(), which is not holding trx_sys->mutex. This bug is specific to the MariaDB 10.2 series. The ReadView was introduced in MariaDB 10.2.2 by merging the code that had been introduced in MySQL 5.7.2. In MariaDB 10.3, ReadView::snapshot() would use the lock-free trx_sys.rw_trx_hash. MDEV-14638 moved the corresponding assertion to trx_sys_t::find(), where it was duly protected by trx->mutex, and later MDEV-14756 moved the check to rw_trx_hash_t::validate_element(). This check was correctly adjusted when MDEV-15772 was merged to 10.3.
1 parent 49ef1c7 commit e0271a7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

storage/innobase/read/read0read.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2019, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -430,8 +431,16 @@ ReadView::copy_trx_ids(const trx_ids_t& trx_ids)
430431

431432
trx_t* trx = trx_get_rw_trx_by_id(*it);
432433
ut_ad(trx != NULL);
433-
ut_ad(trx->state == TRX_STATE_ACTIVE
434-
|| trx->state == TRX_STATE_PREPARED);
434+
switch (trx->state) {
435+
case TRX_STATE_ACTIVE:
436+
case TRX_STATE_PREPARED:
437+
case TRX_STATE_PREPARED_RECOVERED:
438+
case TRX_STATE_COMMITTED_IN_MEMORY:
439+
continue;
440+
case TRX_STATE_NOT_STARTED:
441+
break;
442+
}
443+
ut_ad(!"invalid state");
435444
}
436445
#endif /* UNIV_DEBUG */
437446
}

0 commit comments

Comments
 (0)