Make runOnTransactionIdleCallbacks() handle dangling transactions
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 3 Nov 2015 21:12:14 +0000 (13:12 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 3 Nov 2015 21:12:14 +0000 (13:12 -0800)
This avoids "Got COMMIT while atomic sections X are still open"
if the this DB had active transactions when an error occurred.

Change-Id: I1e2eb3a3382537108ecb269c483d2e62a218b656

includes/db/Database.php

index 531086b..943667e 100644 (file)
@@ -3314,6 +3314,11 @@ abstract class DatabaseBase implements IDatabase {
                                                MWExceptionHandler::logException( $ePrior );
                                        }
                                        $ePrior = $e;
+                                       // Some callbacks may use startAtomic/endAtomic, so make sure
+                                       // their transactions are ended so other callbacks don't fail
+                                       if ( $this->trxLevel() ) {
+                                               $this->rollback( __METHOD__ );
+                                       }
                                }
                        }
                } while ( count( $this->mTrxIdleCallbacks ) );