From 31408b7fefc3621461542bba6e81d019e40025bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Sat, 15 May 2021 10:09:28 +0200 Subject: [PATCH] Silence transaction profiler warnings in ExternalStoreDB::fetchBlob() ExternalStoreDB falls back to a primary connection if the blobs with the specified ID weren't found with the normal connection. Since the ExternalStore abstraction layer hides the fact that there are database connections involved, the caller has no way to control this behavior, so there is no point in emitting warnings when it happens on GET. Bug: T282145 Change-Id: I7f8113230e4b6493b8bdb96e639781ab9c116397 --- includes/externalstore/ExternalStoreDB.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php index 7efa2841123..b683decc831 100644 --- a/includes/externalstore/ExternalStoreDB.php +++ b/includes/externalstore/ExternalStoreDB.php @@ -27,6 +27,7 @@ use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\ILoadBalancer; use Wikimedia\Rdbms\LBFactory; use Wikimedia\Rdbms\MaintainableDBConnRef; +use Wikimedia\ScopedCallback; /** * DB accessible external objects. @@ -317,8 +318,9 @@ class ExternalStoreDB extends ExternalStoreMedium { __METHOD__ ); if ( $ret === false ) { - $this->logger->warning( __METHOD__ . ": master fallback on $cacheID" ); // Try the master + $this->logger->warning( __METHOD__ . ": master fallback on $cacheID" ); + $scope = $this->lbFactory->getTransactionProfiler()->silenceForScope(); $dbw = $this->getMaster( $cluster ); $ret = $dbw->selectField( $this->getTable( $dbw, $cluster ), @@ -326,6 +328,7 @@ class ExternalStoreDB extends ExternalStoreMedium { [ 'blob_id' => $id ], __METHOD__ ); + ScopedCallback::consume( $scope ); if ( $ret === false ) { $this->logger->warning( __METHOD__ . ": master failed to find $cacheID" ); } @@ -362,17 +365,19 @@ class ExternalStoreDB extends ExternalStoreMedium { $this->mergeBatchResult( $ret, $ids, $res ); } if ( $ids ) { + // Try the primary $this->logger->info( __METHOD__ . ": primary fallback on '$cluster' for: " . implode( ',', array_keys( $ids ) ) ); - // Try the primary + $scope = $this->lbFactory->getTransactionProfiler()->silenceForScope(); $dbw = $this->getMaster( $cluster ); $res = $dbw->select( $this->getTable( $dbr, $cluster ), [ 'blob_id', 'blob_text' ], [ 'blob_id' => array_keys( $ids ) ], __METHOD__ ); + ScopedCallback::consume( $scope ); if ( $res === false ) { $this->logger->error( __METHOD__ . ": primary failed on '$cluster'" ); } else {