Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/302289
Change subject: Revert "Automatically detect READ_ONLY mode for MySQL/MariaDB"
......................................................................
Revert "Automatically detect READ_ONLY mode for MySQL/MariaDB"
This reverts commit f4bf52e84388ad0d1d270aac9092b49f05bfc988.
Change-Id: Ifacaf90ca91c9454178ecd536eba9beebd24c663
---
M includes/db/DBConnRef.php
M includes/db/Database.php
M includes/db/DatabaseMysqlBase.php
M includes/db/IDatabase.php
M includes/db/loadbalancer/LoadBalancer.php
5 files changed, 2 insertions(+), 55 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/89/302289/1
diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php
index 53862b9..1893c73 100644
--- a/includes/db/DBConnRef.php
+++ b/includes/db/DBConnRef.php
@@ -417,10 +417,6 @@
return $this->__call( __FUNCTION__, func_get_args() );
}
- public function serverIsReadOnly() {
- return $this->__call( __FUNCTION__, func_get_args() );
- }
-
public function onTransactionResolution( callable $callback ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
diff --git a/includes/db/Database.php b/includes/db/Database.php
index 3dc6e92..2e3e225 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -2456,10 +2456,6 @@
return false;
}
- public function serverIsReadOnly() {
- return false;
- }
-
final public function onTransactionResolution( callable $callback ) {
if ( !$this->mTrxLevel ) {
throw new DBUnexpectedError( $this, "No transaction is
active." );
diff --git a/includes/db/DatabaseMysqlBase.php
b/includes/db/DatabaseMysqlBase.php
index a6f8c31..02a8d30 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -885,13 +885,6 @@
}
}
- public function serverIsReadOnly() {
- $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'read_only'",
__METHOD__ );
- $row = $this->fetchObject( $res );
-
- return $row ? ( strtolower( $row->Value ) === 'on' ) : false;
- }
-
/**
* @param string $index
* @return string
diff --git a/includes/db/IDatabase.php b/includes/db/IDatabase.php
index 41b131f..aa2a980 100644
--- a/includes/db/IDatabase.php
+++ b/includes/db/IDatabase.php
@@ -1221,12 +1221,6 @@
public function getMasterPos();
/**
- * @return bool Whether the DB is marked as read-only server-side
- * @since 1.28
- */
- public function serverIsReadOnly();
-
- /**
* Run a callback as soon as the current transaction commits or rolls
back.
* An error is thrown if no transaction is pending. Queries in the
function will run in
* AUTO-COMMIT mode unless there are begin() calls. Callbacks must
commit any transactions
diff --git a/includes/db/loadbalancer/LoadBalancer.php
b/includes/db/loadbalancer/LoadBalancer.php
index 2543958..a67eac1 100644
--- a/includes/db/loadbalancer/LoadBalancer.php
+++ b/includes/db/loadbalancer/LoadBalancer.php
@@ -49,8 +49,6 @@
private $mLoadMonitor;
/** @var BagOStuff */
private $srvCache;
- /** @var WANObjectCache */
- private $wanCache;
/** @var bool|DatabaseBase Database connection that caused a problem */
private $mErrorConnection;
@@ -78,8 +76,6 @@
const MAX_LAG = 10;
/** @var integer Max time to wait for a slave to catch up (e.g.
ChronologyProtector) */
const POS_WAIT_TIMEOUT = 10;
- /** @var integer Seconds to cache master server read-only status */
- const TTL_CACHE_READONLY = 5;
/**
* @var boolean
@@ -139,7 +135,6 @@
}
$this->srvCache = ObjectCache::getLocalServerInstance();
- $this->wanCache = ObjectCache::getMainWANInstance();
if ( isset( $params['trxProfiler'] ) ) {
$this->trxProfiler = $params['trxProfiler'];
@@ -583,7 +578,7 @@
if ( $masterOnly ) {
# Make master-requested DB handles inherit any
read-only mode setting
- $conn->setLBInfo( 'readOnlyReason',
$this->getReadOnlyReason( $wiki, $conn ) );
+ $conn->setLBInfo( 'readOnlyReason',
$this->getReadOnlyReason( $wiki ) );
}
return $conn;
@@ -1279,11 +1274,10 @@
/**
* @note This method may trigger a DB connection if not yet done
* @param string|bool $wiki Wiki ID, or false for the current wiki
- * @param DatabaseBase|null DB master connection; used to avoid loops
[optional]
* @return string|bool Reason the master is read-only or false if it is
not
* @since 1.27
*/
- public function getReadOnlyReason( $wiki = false, DatabaseBase $conn =
null ) {
+ public function getReadOnlyReason( $wiki = false ) {
if ( $this->readOnlyReason !== false ) {
return $this->readOnlyReason;
} elseif ( $this->getLaggedSlaveMode( $wiki ) ) {
@@ -1294,35 +1288,9 @@
return 'The database has been automatically
locked ' .
'while the slave database servers catch
up to the master.';
}
- } elseif ( $this->masterRunningReadOnly( $wiki, $conn ) ) {
- return 'The database master is running in read-only
mode.';
}
return false;
- }
-
- /**
- * @param string $wiki Wiki ID, or false for the current wiki
- * @param DatabaseBase|null DB master connectionl used to avoid loops
[optional]
- * @return bool
- */
- private function masterRunningReadOnly( $wiki, DatabaseBase $conn =
null ) {
- $cache = $this->wanCache;
- $masterServer = $this->getServerName( $this->getWriterIndex() );
-
- return (bool)$cache->getWithSetCallback(
- $cache->makeGlobalKey( __CLASS__, 'server-read-only',
$masterServer ),
- self::TTL_CACHE_READONLY,
- function () use ( $wiki, $conn ) {
- try {
- $dbw = $conn ?: $this->getConnection(
DB_MASTER, [], $wiki );
- return (int)$dbw->serverIsReadOnly();
- } catch ( DBError $e ) {
- return 0;
- }
- },
- [ 'pcTTL' => $cache::TTL_PROC_LONG, 'busyValue' => 0 ]
- );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/302289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifacaf90ca91c9454178ecd536eba9beebd24c663
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits