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

Command icon 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:

Comments

mondrake created an issue. See original summary.

daffie’s picture

Title: [PP-1] Rolling back to a savepoint should leave the savepoint in the transaction stack » Rolling back to a savepoint should leave the savepoint in the transaction stack
Status: Postponed » Active
mondrake’s picture

Title: Rolling back to a savepoint should leave the savepoint in the transaction stack » [PP-1] Rolling back to a savepoint should leave the savepoint in the transaction stack
Status: Active » Postponed

mondrake’s picture

Title: [PP-1] Rolling back to a savepoint should leave the savepoint in the transaction stack » Rolling back to a savepoint should leave the savepoint in the transaction stack
Status: Postponed » Needs work
mondrake’s picture

Status: Needs work » Needs review
daffie’s picture

Status: Needs review » Reviewed & tested by the community

All the code changes look good to me.
For me it is RTBC.

daffie’s picture

Priority: Normal » Critical

Changing the priority to critical as without this fix it could result into a data loss situation.

  • catch committed 666f9e98 on 11.x
    Issue #3384997 by mondrake, daffie: Rolling back to a savepoint should...
catch’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!

  • catch committed dbb4e525 on 10.2.x
    Issue #3384997 by mondrake, daffie: Rolling back to a savepoint should...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.