Merge "Support non-replicating DB clusters for static datasets"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 24 May 2016 23:59:24 +0000 (23:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 24 May 2016 23:59:24 +0000 (23:59 +0000)
includes/DefaultSettings.php
includes/db/DatabaseMysqlBase.php
includes/db/loadbalancer/LoadBalancer.php

index 3257b3a..cef0215 100644 (file)
@@ -1902,6 +1902,7 @@ $wgSharedSchema = false;
  *                                    if available
  *
  *   - max lag:     (optional) Maximum replication lag before a slave will taken out of rotation
+ *   - is static:   (optional) Set to true if the dataset is static and no replication is used.
  *
  *   These and any other user-defined properties will be assigned to the mLBInfo member
  *   variable of the Database object.
index 13be911..3ebc3ec 100644 (file)
@@ -782,8 +782,10 @@ abstract class DatabaseMysqlBase extends Database {
                        throw new InvalidArgumentException( "Position not an instance of MySQLMasterPos" );
                }
 
-               if ( $this->lastKnownSlavePos && $this->lastKnownSlavePos->hasReached( $pos ) ) {
-                       return 0;
+               if ( $this->getLBInfo( 'is static' ) === true ) {
+                       return 0; // this is a copy of a read-only dataset with no master DB
+               } elseif ( $this->lastKnownSlavePos && $this->lastKnownSlavePos->hasReached( $pos ) ) {
+                       return 0; // already reached this point for sure
                }
 
                # Commit any open transactions
index 1f2f494..d96c665 100644 (file)
@@ -1402,7 +1402,7 @@ class LoadBalancer {
                }
 
                $pos = $pos ?: $this->getConnection( DB_MASTER )->getMasterPos();
-               if ( !$pos ) {
+               if ( !( $pos instanceof DBMasterPos ) ) {
                        return false; // something is misconfigured
                }