Problem/Motivation
When rolling back to a savepoint, we are currently removing the reference to the Transaction object in the stack. This means that a later release or rollback of the same savepoint on the database is not happening.
However, per MySQL docs (emphasis mine), https://dev.mysql.com/doc/refman/8.0/en/savepoint.html:
The ROLLBACK TO SAVEPOINT statement rolls back a transaction to the named savepoint without terminating the transaction. Modifications that the current transaction made to rows after the savepoint was set are undone in the rollback, but InnoDB does not release the row locks that were stored in memory after the savepoint. (For a new inserted row, the lock information is carried by the transaction ID stored in the row; the lock is not separately stored in memory. In this case, the row lock is released in the undo.) Savepoints that were set at a later time than the named savepoint are deleted.
So if I am reading this correctly, the savepoint rolled back to remains actually active, and we should not remove it from our transaction stack.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3384997
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3384997-pp-1-rolling-back
changes, plain diff MR !4908
Comments
Comment #2
daffie commentedComment #3
mondrakePostponed on #3384995: Committing a transaction while there are still active savepoints leaves the stack in inconsistent state
Comment #5
mondrakeNeeds a rebase now that #3384995: Committing a transaction while there are still active savepoints leaves the stack in inconsistent state went in.
Comment #6
mondrakeComment #7
daffie commentedAll the code changes look good to me.
For me it is RTBC.
Comment #8
daffie commentedChanging the priority to critical as without this fix it could result into a data loss situation.
Comment #10
catchCommitted/pushed to 11.x and cherry-picked to 10.2.x, thanks!