Commit e0271a7b authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 49ef1c75
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software 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) ...@@ -430,8 +431,16 @@ ReadView::copy_trx_ids(const trx_ids_t& trx_ids)
trx_t* trx = trx_get_rw_trx_by_id(*it); trx_t* trx = trx_get_rw_trx_by_id(*it);
ut_ad(trx != NULL); ut_ad(trx != NULL);
ut_ad(trx->state == TRX_STATE_ACTIVE switch (trx->state) {
|| trx->state == TRX_STATE_PREPARED); case TRX_STATE_ACTIVE:
case TRX_STATE_PREPARED:
case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
continue;
case TRX_STATE_NOT_STARTED:
break;
}
ut_ad(!"invalid state");
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment