-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-37229: Set proper trx isolation level before every applied event #4422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 10.11
Are you sure you want to change the base?
MDEV-37229: Set proper trx isolation level before every applied event #4422
Conversation
|
|
Every applier thread in Galera should run with READ_COMMITTED transaction isolation level to prevent applying issues caused by InnoDB gap locks. The exception is statement-based replication, where REPEATABLE_READ is required by the server code. Apparently, there was a separate issue with applier thread variables: wsrep_plugins_post_init() would overwrite thd->variables for every applier thread and forget to restore proper default isolation level. Then, upon every server transaction termination, trans_reset_one_shot_statistics() would set thread's isolation level to the one stored in thd->variables, thus spoiling the isolation level value for appliers.
4eff7de to
31f544d
Compare
| } | ||
| } | ||
|
|
||
| /* Statement-based replication requires InnoDB repeatable read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some elaboration is needed in this comment:
- As the transaction is already started in
Wsrep_high_priority_service::start_transaction(), is the change ofthd->tx_isolationfully effective here or does it just suppress some server level checks? - Is it possible that the write set contains both row and query events? In this case a row event could start a transaction with
ISO_READ_COMMITTEDand the following query event would be actually executed with read-committed isolation as thethd->tx_isolationis effective only when the transaction is started. - Should this apply only to DML or also to DDLs (which are replicated as TOI)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- it seems that changing the isolation level only affects server transactions that haven't started yet (maybe some extra check should be performed to determine if we have a transaction already running and skip this code)
- I don't know, but there's a mixed replication setting available. If intermixing row and query events is allowed, then we're in trouble. I don't see a good way of fixing that except we specifically add a documentation statement that such mode should not be used on the producer (master)
- the isolation level is reset to default after every applied event, so TOI will run with read committed. As we're replicating SQL statements with TOI, maybe read committed is enough? Ideally, we might want to replicate the isolation level used for TOI on the initiator node, but I don't think it's possible right now.
Description
Every applier thread in Galera should run with READ_COMMITTED transaction isolation level to prevent applying issues caused by InnoDB gap locks. The exception is statement-based replication, where REPEATABLE_READ is required by the server code.
Apparently, there was a separate issue with applier thread variables: wsrep_plugins_post_init() would overwrite thd->variables for every applier thread and forget to restore proper default isolation level. Then, upon every server transaction termination,
trans_reset_one_shot_statistics() would set thread's isolation level to the one stored in thd->variables, thus spoiling the isolation level value for appliers.
Release Notes
TODO: What should the release notes say about this change?
Include any changed system variables, status variables or behaviour. Optionally list any https://mariadb.com/kb/ pages that need changing.
How can this PR be tested?
MTR test is updated.
Basing the PR against the correct MariaDB version
mainbranch.PR quality check