MDEV-40144 InnoDB: Add instant rollback#5272
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the Instant Rollback (IRB) feature for InnoDB, which includes new system variables, lock release mechanisms, and integration into the transaction rollback and crash recovery paths. The review feedback highlights several critical and high-severity issues: a potential infinite loop/hang in lock_release_record_locks_from_list when processing 1000 or more table locks, performance overhead from heap-allocating irb_row_t in row_undo, excessive warning logs for transactions that do not qualify for instant rollback, and an inappropriate error log level during crash recovery when the threshold is not met.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
1d6215f to
9944864
Compare
|
Addressed in the latest revision:
|
cfe7db2 to
a45ad39
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution. This is a preliminary review.
The PR is formally correct, hence I'm approving it.
However there's 2 things to look at:
- make sure the mariabackup.apply-log-only-incr failure is not related. It's the first time I'm seeing this happening.
- keep a single commit per "feature". In your case you have the perfectly formatted commit and then a merge commit. If you want to (re-)merge the origin branch please use "rebase" in the github UI.
Please stand by for the final review.
|
Hi annbaek / shimengchu, This is an interesting idea. Both the idea to release locks early during I don't quite understand how the patch works though. What I see is that in row_undo(), it accumulates in the irb_row_t context So does this mean that only new record locks created during undo processing Or do any existing record locks of the transaction-to-be-rolled-back get Basically, my question is how the order of the different steps of rollback Another question, these parts of the patch appear to do nothing: The save_recs_info() function is called but does nothing, and the
|
1211ca8 to
5036436
Compare
Large transactions may spend a long time rolling back, either during crash recovery or after an explicit ROLLBACK. During that time the server can keep record locks for work that is only needed while the rollback thread is applying undo records. Add an instant rollback mode for InnoDB transactions whose undo record count reaches the configured threshold. When enabled, InnoDB releases the transaction's existing record locks before full rollback continues. The rollback still runs in the original rollback thread, and row undo collects any temporary IRB record locks in a per-row context so they can be released after each undo record. This introduces innodb_instant_rollback_enabled and innodb_instant_rollback_threshold, tracks instant rollback state in trx_t, and handles both recovered transactions and normal explicit rollback. Transactions that do not qualify keep the existing rollback flow. Add innodb.feature_instant_rollback coverage for both crash recovery and explicit ROLLBACK.
5036436 to
0afd3fd
Compare
Thanks for the preliminary review. I rebased the branch on the latest main and force-pushed it as a single feature commit. The merge commit has been removed. I also added coverage for the explicit ROLLBACK case and re-ran the targeted tests locally:
All passed locally. I do not see this change touching the mariabackup.apply-log-only-incr path directly, but I will check again if CI still reproduces a related failure. |
Thanks for the detailed questions. The empty helpers were leftovers from an earlier two-phase plan. I removed them to avoid suggesting behavior that was not implemented. The implemented IRB behavior now covers both recovered transactions and explicit ROLLBACK:
I also added a test for explicit ROLLBACK. It pauses the rollback thread after row undo starts, then verifies that another transaction can update a record previously locked by the rolling-back transaction. This covers the early release of existing |
|
annbaek ***@***.***> writes:
The implemented IRB behavior now covers both recovered transactions and explicit ROLLBACK:
<snip>
Thanks for the additional explanation, that helps a lot. I missed how
consider_instant_rollback_normal_trxs() calls lock_release_record_locks() to
release locks early, that makes sense now.
The empty helpers were leftovers from an earlier two-phase plan. I
removed them to avoid suggesting behavior that was not implemented.
I see, that also makes sense.
I'm not intimately familiar with InnoDB locking and undo/rollback (the
InnoDB devs will have to look deeper into this), but it is an interesting
idea, and I appreciate the additional explanation.
\- Kristian.
|
Large transactions may spend a long time rolling back after crash recovery. During that time the server keeps rollback state and record locks for work that is only needed to make the old transaction effects disappear.
Add an instant rollback mode for InnoDB transactions whose undo record count reaches the configured threshold. When enabled, InnoDB can release record locks for the transaction and let individual row access handle the remaining undo state instead of running the full recovered transaction rollback immediately.
This introduces innodb_instant_rollback_enabled and innodb_instant_rollback_threshold, tracks instant rollback state in trx_t, and adds helper logic for recovered and normal rollback paths. The row undo and lock code are extended to collect and release temporary IRB record locks while preserving the existing rollback flow for transactions that do not qualify.
Add innodb.feature_instant_rollback to cover the crash recovery case with instant rollback enabled.