Support non-replicating DB clusters for static datasets
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 18 May 2016 23:03:27 +0000 (16:03 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 18 May 2016 23:03:27 +0000 (16:03 -0700)
* Make the slave wait methods work properly in this case if
  the config flag is set.
* Also fixed a small IDEA error.

Bug: T135690
Change-Id: I9a12f1fc54c0b426f64c19ac2bf720e683fcf2fe

includes/DefaultSettings.php
includes/db/DatabaseMysqlBase.php
includes/db/loadbalancer/LoadBalancer.php

index d6db388..a542ed8 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 5578099..43da218 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
                }