Merge "Database transaction flushing cleanups"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 16 Aug 2016 22:03:43 +0000 (22:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 16 Aug 2016 22:03:43 +0000 (22:03 +0000)
1  2 
includes/WatchedItemStore.php
includes/db/Database.php

@@@ -741,6 -741,7 +741,7 @@@ class WatchedItemStore implements Stats
                                        global $wgUpdateRowsPerQuery;
  
                                        $dbw = $this->getConnection( DB_MASTER );
+                                       $factory = wfGetLBFactory();
  
                                        $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery );
                                        foreach ( $watchersChunks as $watchersChunk ) {
                                                        ], $fname
                                                );
                                                if ( count( $watchersChunks ) > 1 ) {
-                                                       $dbw->commit( __METHOD__, 'flush' );
-                                                       wfGetLBFactory()->waitForReplication( [ 'wiki' => $dbw->getWikiID() ] );
+                                                       $factory->commitMasterChanges( __METHOD__ );
+                                                       $factory->waitForReplication( [ 'wiki' => $dbw->getWikiID() ] );
                                                }
                                        }
                                        $this->uncacheLinkTarget( $target );
  
                                        $this->reuseConnection( $dbw );
 -                              }
 +                              },
 +                              DeferredUpdates::POSTSEND,
 +                              $dbw
                        );
                }
  
diff --combined includes/db/Database.php
@@@ -703,7 -703,7 +703,7 @@@ abstract class DatabaseBase implements 
                                                " performing implicit commit before closing connection!" );
                                }
  
-                               $this->commit( __METHOD__, 'flush' );
+                               $this->commit( __METHOD__, self::FLUSHING_INTERNAL );
                        }
  
                        $closed = $this->closeConnection();
        /**
         * Gets an array of aliased table names
         *
 -       * @param array $tables Array( [alias] => table )
 +       * @param array $tables [ [alias] => table ]
         * @return string[] See tableNameWithAlias()
         */
        public function tableNamesWithAlias( $tables ) {
        /**
         * Gets an array of aliased field names
         *
 -       * @param array $fields Array( [alias] => field )
 +       * @param array $fields [ [alias] => field ]
         * @return string[] See fieldNameWithAlias()
         */
        public function fieldNamesWithAlias( $fields ) {
                }
  
                if ( !$this->mTrxAtomicLevels && $this->mTrxAutomaticAtomic ) {
-                       $this->commit( $fname, 'flush' );
+                       $this->commit( $fname, self::FLUSHING_INTERNAL );
                }
        }
  
                        );
                }
  
-               if ( $flush === 'flush' ) {
+               if ( $flush === self::FLUSHING_INTERNAL || $flush === self::FLUSHING_ALL_PEERS ) {
                        if ( !$this->mTrxLevel ) {
                                return; // nothing to do
                        } elseif ( !$this->mTrxAutomatic ) {
        }
  
        final public function rollback( $fname = __METHOD__, $flush = '' ) {
-               if ( $flush !== 'flush' ) {
+               if ( $flush !== self::FLUSHING_INTERNAL && $flush !== self::FLUSHING_ALL_PEERS ) {
                        if ( !$this->mTrxLevel ) {
                                wfWarn( "$fname: No transaction to rollback, something got out of sync!" );
                                return; // nothing to do
                }
  
                $unlocker = new ScopedCallback( function () use ( $lockKey, $fname ) {
-                       $this->commit( __METHOD__, 'flush' );
+                       $this->commit( __METHOD__, self::FLUSHING_INTERNAL );
                        $this->unlock( $lockKey, $fname );
                } );
  
-               $this->commit( __METHOD__, 'flush' );
+               $this->commit( __METHOD__, self::FLUSHING_INTERNAL );
  
                return $unlocker;
        }