From: Aaron Schulz Date: Wed, 18 May 2016 23:03:27 +0000 (-0700) Subject: Support non-replicating DB clusters for static datasets X-Git-Tag: 1.31.0-rc.0~6835^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=dad87efa5a431a06a4a379b606346cf93d85ae7d;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 }