Savepoints were lingering and/or not setup properly by the engines because the transaction was not started properly when a SAVEPOINT (or even ROLLBACK TO SAVEPOINT) implicitly begins a new transaction with AUTOCOMMIT=OFF.
If an implicit transaction is started by a statement that touches tables, the call to startStatement() from lockTables() would automatically start a transaction if one was needed. Since savepoints don't go through this code, we needed checks to look for this case.
Savepoints were lingering and/or not setup properly by the engines because the transaction was not started properly when a SAVEPOINT (or even ROLLBACK TO SAVEPOINT) implicitly begins a new transaction with AUTOCOMMIT=OFF.
If an implicit transaction is started by a statement that touches tables, the call to startStatement() from lockTables() would automatically start a transaction if one was needed. Since savepoints don't go through this code, we needed checks to look for this case.