server
server copied to clipboard
MDEV-33064: Sync trx->wsrep state from THD on trx start
- [x] The Jira issue number for this PR is: MDEV-33064
Description
InnoDB transactions may be reused after committed:
- when taken from the transaction pool
- during a DDL operation execution
In this case wsrep flag on trx object is cleared, which may cause wrong execution logic afterwards (wsrep-related hooks are not run).
Make trx->wsrep flag initialize from THD object only once on InnoDB transaction start and don't change it throughout the transaction's lifetime. The flag is reset at commit time as before.
Unconditionally set wsrep=OFF for THD objects that represent InnoDB background threads.
Make Wsrep_schema::store_view() operate in its own transaction.
Fix streaming replication transactions' fragments rollback to not switch THD->wsrep value during transaction's execution (use THD->wsrep_ignore_table as a workaround).
How can this PR be tested?
MTR test is provided.
Basing the PR against the correct MariaDB version
- [ ] This is a new feature and the PR is based against the latest MariaDB development branch.
- [x] This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.
PR quality check
- [x] I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
- [x] For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
In trx_rollback_for_mysql()
, there still is an assignment trx->wsrep= false
. I think that it should be replaced with ut_ad(!trx->is_wsrep())
.
After that, the only assignments from/to nonzero would be in trx_start_low()
and trx_t::commit_in_memory()
. I think that the assignment in trx_t::commit_in_memory()
as well as the original zero-initialization of the transaction pool should guarantee that the assertion that I am suggesting would hold in trx_rollback_for_mysql()
. I see that we already have ut_ad(!is_wsrep())
in trx_t::assert_freed()
.
Indeed, for a not started transaction it looks safe to place an assertion on trx->wsrep
rather than the assignment. Fixed it in a separate commit.