From dad87efa5a431a06a4a379b606346cf93d85ae7d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 18 May 2016 16:03:27 -0700 Subject: [PATCH] Support non-replicating DB clusters for static datasets * 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 | 1 + includes/db/DatabaseMysqlBase.php | 6 ++++-- includes/db/loadbalancer/LoadBalancer.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d6db388573..a542ed84e9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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. diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index 13be911686..3ebc3ecce1 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -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 diff --git a/includes/db/loadbalancer/LoadBalancer.php b/includes/db/loadbalancer/LoadBalancer.php index 557809905c..43da2180ff 100644 --- a/includes/db/loadbalancer/LoadBalancer.php +++ b/includes/db/loadbalancer/LoadBalancer.php @@ -1402,7 +1402,7 @@ class LoadBalancer { } $pos = $pos ?: $this->getConnection( DB_MASTER )->getMasterPos(); - if ( !$pos ) { + if ( !( $pos instanceof DBMasterPos ) ) { return false; // something is misconfigured } -- 2.20.1