Merge "Add ability to filter based on rc_title in API"
[lhc/web/wiklou.git] / includes / libs / rdbms / loadbalancer / ILoadBalancer.php
index fec496e..81ce4ba 100644 (file)
@@ -89,6 +89,11 @@ interface ILoadBalancer {
        /** @var int Alias for CONN_TRX_AUTOCOMMIT for b/c; deprecated since 1.31 */
        const CONN_TRX_AUTO = 1;
 
+       /** @var string Manager of ILoadBalancer instances is running post-commit callbacks */
+       const STAGE_POSTCOMMIT_CALLBACKS = 'stage-postcommit-callbacks';
+       /** @var string Manager of ILoadBalancer instances is running post-rollback callbacks */
+       const STAGE_POSTROLLBACK_CALLBACKS = 'stage-postrollback-callbacks';
+
        /**
         * Construct a manager of IDatabase connection objects
         *
@@ -112,6 +117,7 @@ interface ILoadBalancer {
         *  - perfLogger: PSR-3 logger instance. [optional]
         *  - errorLogger : Callback that takes an Exception and logs it. [optional]
         *  - deprecationLogger: Callback to log a deprecation warning. [optional]
+        *  - roundStage: STAGE_POSTCOMMIT_* class constant; for internal use [optional]
         * @throws InvalidArgumentException
         */
        public function __construct( array $params );
@@ -377,10 +383,11 @@ interface ILoadBalancer {
        public function commitAll( $fname = __METHOD__ );
 
        /**
-        * Perform all pre-commit callbacks that remain part of the atomic transactions
-        * and disable any post-commit callbacks until runMasterPostTrxCallbacks()
+        * Run pre-commit callbacks and defer execution of post-commit callbacks
         *
         * Use this only for mutli-database commits
+        *
+        * @return int Number of pre-commit callbacks run (since 1.32)
         */
        public function finalizeMasterChanges();
 
@@ -417,14 +424,18 @@ interface ILoadBalancer {
        public function commitMasterChanges( $fname = __METHOD__ );
 
        /**
-        * Issue all pending post-COMMIT/ROLLBACK callbacks
+        * Consume and run all pending post-COMMIT/ROLLBACK callbacks and commit dangling transactions
         *
-        * Use this only for mutli-database commits
+        * @return Exception|null The first exception or null if there were none
+        */
+       public function runMasterTransactionIdleCallbacks();
+
+       /**
+        * Run all recurring post-COMMIT/ROLLBACK listener callbacks
         *
-        * @param int $type IDatabase::TRIGGER_* constant
         * @return Exception|null The first exception or null if there were none
         */
-       public function runMasterPostTrxCallbacks( $type );
+       public function runMasterTransactionListenerCallbacks();
 
        /**
         * Issue ROLLBACK only on master, only if queries were done on connection
@@ -434,20 +445,20 @@ interface ILoadBalancer {
        public function rollbackMasterChanges( $fname = __METHOD__ );
 
        /**
-        * Suppress all pending post-COMMIT/ROLLBACK callbacks
+        * Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshots
         *
-        * Use this only for mutli-database commits
-        *
-        * @return Exception|null The first exception or null if there were none
+        * @param string $fname Caller name
         */
-       public function suppressTransactionEndCallbacks();
+       public function flushReplicaSnapshots( $fname = __METHOD__ );
 
        /**
-        * Commit all replica DB transactions so as to flush any REPEATABLE-READ or SSI snapshot
+        * Commit all master DB transactions so as to flush any REPEATABLE-READ or SSI snapshots
+        *
+        * An error will be thrown if a connection has pending writes or callbacks
         *
         * @param string $fname Caller name
         */
-       public function flushReplicaSnapshots( $fname = __METHOD__ );
+       public function flushMasterSnapshots( $fname = __METHOD__ );
 
        /**
         * @return bool Whether a master connection is already open
@@ -455,7 +466,7 @@ interface ILoadBalancer {
        public function hasMasterConnection();
 
        /**
-        * Determine if there are pending changes in a transaction by this thread
+        * Whether there are pending changes or callbacks in a transaction by this thread
         * @return bool
         */
        public function hasMasterChanges();