Manybubbles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/214772

Change subject: WIP: Commit all connections after each job
......................................................................

WIP: Commit all connections after each job

If you don't commit the slave connections then they keep their old snapshots.
This clears the snapshots so they don't get out of date views of the world.

Bug: T100838
Change-Id: I1f6f910d88324beb589b2ad9466d8786376eda55
---
M includes/db/LBFactory.php
M includes/jobqueue/JobRunner.php
2 files changed, 16 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/72/214772/1

diff --git a/includes/db/LBFactory.php b/includes/db/LBFactory.php
index 4551e2d..0fbe4fd 100644
--- a/includes/db/LBFactory.php
+++ b/includes/db/LBFactory.php
@@ -178,6 +178,15 @@
        }
 
        /**
+        * Commit on all connections. Done for two reasons:
+        * 1. To commit changes to the masters.
+        * 2. To release the snapshot on slaves.
+        */
+       public function commitAll() {
+               $this->forEachLBCallMethod( 'commitAll' );
+       }
+
+       /**
         * Commit changes on all master connections
         */
        public function commitMasterChanges() {
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index b04ab28..710a867 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -128,7 +128,7 @@
                $group = JobQueueGroup::singleton();
                
                // Flush any pending DB writes for sanity
-               wfGetLBFactory()->commitMasterChanges();
+               wfGetLBFactory()->commitAll();
 
                // Some jobs types should not run until a certain timestamp
                $backoffs = array(); // map of (type => UNIX expiry)
@@ -180,12 +180,13 @@
                                        ++$jobsRun;
                                        $status = $job->run();
                                        $error = $job->getLastError();
-                                       $this->commitMasterChanges( $job );
+                                       $this->commitAll( $job );
 
                                        DeferredUpdates::doUpdates();
-                                       $this->commitMasterChanges( $job );
+                                       $this->commitAll( $job );
                                } catch ( Exception $e ) {
                                        
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+                                       // TODO this doesn't release the slave 
snapshots
                                        $status = false;
                                        $error = get_class( $e ) . ': ' . 
$e->getMessage();
                                        MWExceptionHandler::logException( $e );
@@ -415,7 +416,7 @@
         * @param Job $job
         * @throws DBError
         */
-       private function commitMasterChanges( Job $job ) {
+       private function commitAll( Job $job ) {
                global $wgJobSerialCommitThreshold;
 
                $lb = wfGetLB( wfWikiID() );
@@ -432,7 +433,7 @@
                ) {
                        // Writes are all to foreign DBs, named locks don't 
form queues,
                        // or $wgJobSerialCommitThreshold is not reached; 
commit changes now
-                       wfGetLBFactory()->commitMasterChanges();
+                       wfGetLBFactory()->commitAll();
                        return;
                }
 
@@ -464,7 +465,7 @@
                } );
 
                // Actually commit the DB master changes
-               wfGetLBFactory()->commitMasterChanges();
+               wfGetLBFactory()->commitAll();
 
                // Release the lock
                $dbwSerial->unlock( 'jobrunner-serial-commit', __METHOD__ );

-- 
To view, visit https://gerrit.wikimedia.org/r/214772
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f6f910d88324beb589b2ad9466d8786376eda55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to