jenkins-bot has submitted this change and it was merged. Change subject: Made SqlBagOStuff avoid tripping TransactionProfiler ......................................................................
Made SqlBagOStuff avoid tripping TransactionProfiler * Set a custom profiler with no expectations to avoid tripping the "0 write" expection. This avoids useless log entries. Change-Id: Iac849a729eb36b1a8affb0dbc8b8c195fab4b03a (cherry picked from commit 61df5e785f22748b259c9e71c277e815a0f66e4f) --- M includes/db/Database.php M includes/objectcache/SqlBagOStuff.php 2 files changed, 25 insertions(+), 7 deletions(-) Approvals: Chad: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/db/Database.php b/includes/db/Database.php index 2b79261..04fcfdd 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -153,6 +153,9 @@ */ protected $allViews = null; + /** @var TransactionProfiler */ + protected $trxProfiler; + /** * A string describing the current software version, and possibly * other details in a user-friendly way. Will be listed on Special:Version, etc. @@ -343,6 +346,15 @@ * @param bool $enabled */ public function setFakeMaster( $enabled = true ) { + } + + /** + * @return TransactionProfiler + */ + protected function getTransactionProfiler() { + return $this->trxProfiler + ? $this->trxProfiler + : Profiler::instance()->getTransactionProfiler(); } /** @@ -798,12 +810,16 @@ $this->mForeign = $foreign; + if ( isset( $params['trxProfiler'] ) ) { + $this->trxProfiler = $params['trxProfiler']; // override + } + if ( $user ) { $this->open( $server, $user, $password, $dbName ); } $isMaster = !is_null( $this->getLBInfo( 'master' ) ); - $trxProf = Profiler::instance()->getTransactionProfiler(); + $trxProf = $this->getTransactionProfiler(); $trxProf->recordConnection( $this->mServer, $this->mDBname, $isMaster ); } @@ -1103,7 +1119,7 @@ # Keep track of whether the transaction has write queries pending if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $isWriteQuery ) { $this->mTrxDoneWrites = true; - Profiler::instance()->getTransactionProfiler()->transactionWritingIn( + $this->getTransactionProfiler()->transactionWritingIn( $this->mServer, $this->mDBname, $this->mTrxShortId ); } @@ -1149,7 +1165,7 @@ $startTime = microtime( true ); $ret = $this->doQuery( $commentedSql ); # Log the query time and feed it into the DB trx profiler - $profiler->getTransactionProfiler()->recordQueryCompletion( + $this->getTransactionProfiler()->recordQueryCompletion( $queryProf, $startTime, $isWriteQuery, $this->affectedRows() ); MWDebug::queryTime( $queryId ); @@ -1180,7 +1196,7 @@ $startTime = microtime( true ); $ret = $this->doQuery( $commentedSql ); # Log the query time and feed it into the DB trx profiler - $profiler->getTransactionProfiler()->recordQueryCompletion( + $this->getTransactionProfiler()->recordQueryCompletion( $queryProf, $startTime, $isWriteQuery, $this->affectedRows() ); } } else { @@ -3596,7 +3612,7 @@ $this->runOnTransactionPreCommitCallbacks(); $this->doCommit( $fname ); if ( $this->mTrxDoneWrites ) { - Profiler::instance()->getTransactionProfiler()->transactionWritingOut( + $this->getTransactionProfiler()->transactionWritingOut( $this->mServer, $this->mDBname, $this->mTrxShortId ); } $this->runOnTransactionIdleCallbacks(); @@ -3676,7 +3692,7 @@ $this->runOnTransactionPreCommitCallbacks(); $this->doCommit( $fname ); if ( $this->mTrxDoneWrites ) { - Profiler::instance()->getTransactionProfiler()->transactionWritingOut( + $this->getTransactionProfiler()->transactionWritingOut( $this->mServer, $this->mDBname, $this->mTrxShortId ); } $this->runOnTransactionIdleCallbacks(); @@ -3735,7 +3751,7 @@ $this->mTrxPreCommitCallbacks = array(); // cancel $this->mTrxAtomicLevels = new SplStack; if ( $this->mTrxDoneWrites ) { - Profiler::instance()->getTransactionProfiler()->transactionWritingOut( + $this->getTransactionProfiler()->transactionWritingOut( $this->mServer, $this->mDBname, $this->mTrxShortId ); } } diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 2fb9ff9..82eeb84 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -145,6 +145,8 @@ $type = isset( $info['type'] ) ? $info['type'] : 'mysql'; $host = isset( $info['host'] ) ? $info['host'] : '[unknown]'; $this->logger->debug( __CLASS__ . ": connecting to $host" ); + // Use a blank trx profiler to ignore expections as this is a cache + $info['trxProfiler'] = new TransactionProfiler(); $db = DatabaseBase::factory( $type, $info ); $db->clearFlag( DBO_TRX ); } else { -- To view, visit https://gerrit.wikimedia.org/r/194969 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iac849a729eb36b1a8affb0dbc8b8c195fab4b03a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: wmf/1.25wmf19 Gerrit-Owner: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits