Make Database::rollback() also suppress callback errors
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 4 Oct 2017 18:24:11 +0000 (11:24 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 4 Oct 2017 18:24:14 +0000 (11:24 -0700)
This is consistent with query error suppression, let the
listener callbacks have a chance to run. This also makes
LoadBalancer::rollbackMasterChanges move on to the other
connections.

Change-Id: Ic8b9dd4b868bfe69b04fb20f7be5fce11d864fc4

includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php

index 3c0a2ad..bc1454b 100644 (file)
@@ -3078,8 +3078,16 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
 
                $this->mTrxIdleCallbacks = []; // clear
                $this->mTrxPreCommitCallbacks = []; // clear
-               $this->runOnTransactionIdleCallbacks( self::TRIGGER_ROLLBACK );
-               $this->runTransactionListenerCallbacks( self::TRIGGER_ROLLBACK );
+               try {
+                       $this->runOnTransactionIdleCallbacks( self::TRIGGER_ROLLBACK );
+               } catch ( Exception $e ) {
+                       // already logged; finish and let LoadBalancer move on during mass-rollback
+               }
+               try {
+                       $this->runTransactionListenerCallbacks( self::TRIGGER_ROLLBACK );
+               } catch ( Exception $e ) {
+                       // already logged; let LoadBalancer move on during mass-rollback
+               }
        }
 
        /**
index 5d0e03f..67e8e85 100644 (file)
@@ -1594,6 +1594,8 @@ interface IDatabase {
         * throwing an Exception is preferrable, using a pre-installed error handler to trigger
         * rollback (in any case, failure to issue COMMIT will cause rollback server-side).
         *
+        * Query, connection, and onTransaction* callback errors will be suppressed and logged.
+        *
         * @param string $fname Calling function name
         * @param string $flush Flush flag, set to a situationally valid IDatabase::FLUSHING_*
         *   constant to disable warnings about calling rollback when no transaction is in