From: Aaron Schulz Date: Sat, 30 Jul 2016 20:42:44 +0000 (-0700) Subject: Silence the TransactionProfiler in masterRunningReadOnly() X-Git-Tag: 1.31.0-rc.0~6212^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=a2e3ae5e18cc4f8baefe7fccdb7ed18e0407a325;p=lhc%2Fweb%2Fwiklou.git Silence the TransactionProfiler in masterRunningReadOnly() Change-Id: I93a5cce8c781c1e2ab4fb6bcefd3720e61f8a4dd --- diff --git a/includes/db/loadbalancer/LoadBalancer.php b/includes/db/loadbalancer/LoadBalancer.php index 2543958213..dbf031ebaa 100644 --- a/includes/db/loadbalancer/LoadBalancer.php +++ b/includes/db/loadbalancer/LoadBalancer.php @@ -1314,12 +1314,15 @@ class LoadBalancer { $cache->makeGlobalKey( __CLASS__, 'server-read-only', $masterServer ), self::TTL_CACHE_READONLY, function () use ( $wiki, $conn ) { + $this->trxProfiler->setSilenced( true ); try { $dbw = $conn ?: $this->getConnection( DB_MASTER, [], $wiki ); - return (int)$dbw->serverIsReadOnly(); + $readOnly = (int)$dbw->serverIsReadOnly(); } catch ( DBError $e ) { - return 0; + $readOnly = 0; } + $this->trxProfiler->setSilenced( false ); + return $readOnly; }, [ 'pcTTL' => $cache::TTL_PROC_LONG, 'busyValue' => 0 ] ); diff --git a/includes/profiler/TransactionProfiler.php b/includes/profiler/TransactionProfiler.php index 1aba71c3fa..bf26573cc3 100644 --- a/includes/profiler/TransactionProfiler.php +++ b/includes/profiler/TransactionProfiler.php @@ -38,6 +38,8 @@ class TransactionProfiler implements LoggerAwareInterface { protected $dbLockThreshold = 3.0; /** @var float Seconds */ protected $eventThreshold = .25; + /** @var bool */ + protected $silenced = false; /** @var array transaction ID => (write start time, list of DBs involved) */ protected $dbTrxHoldingLocks = []; @@ -77,6 +79,14 @@ class TransactionProfiler implements LoggerAwareInterface { $this->logger = $logger; } + /** + * @param bool $value + * @since 1.28 + */ + public function setSilenced( $value ) { + $this->silenced = $value; + } + /** * Set performance expectations * @@ -302,6 +312,10 @@ class TransactionProfiler implements LoggerAwareInterface { * @param string|float|int $actual [optional] */ protected function reportExpectationViolated( $expect, $query, $actual = null ) { + if ( $this->silenced ) { + return; + } + $n = $this->expect[$expect]; $by = $this->expectBy[$expect]; $actual = ( $actual !== null ) ? " (actual: $actual)" : "";