From e29538b1b3b832b59442cc1116944c912cc9d471 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 29 Aug 2019 21:53:38 -0700 Subject: [PATCH] rdbms: add more ScopedCallback::newScopedIgnoreUserAbort() calls Place more calls in LBFactory and un-owned LoadBalancer instances Bug: T231443 Change-Id: Id93e70ada114801efe3aa81e865f0a930489bd29 --- includes/libs/rdbms/lbfactory/LBFactory.php | 20 +++++++++-- .../libs/rdbms/loadbalancer/LoadBalancer.php | 36 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 77467f062a..36e961a428 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -160,6 +160,9 @@ abstract class LBFactory implements ILBFactory { } public function destroy() { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + $this->forEachLBCallMethod( 'disable' ); } @@ -177,6 +180,9 @@ abstract class LBFactory implements ILBFactory { &$cpIndex = null, &$cpClientId = null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + $chronProt = $this->getChronologyProtector(); if ( $mode === self::SHUTDOWN_CHRONPROT_SYNC ) { $this->shutdownChronologyProtector( $chronProt, $workCallback, 'sync', $cpIndex ); @@ -250,6 +256,9 @@ abstract class LBFactory implements ILBFactory { final public function beginMasterChanges( $fname = __METHOD__ ) { $this->assertTransactionRoundStage( self::ROUND_CURSORY ); + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + $this->trxRoundStage = self::ROUND_BEGINNING; if ( $this->trxRoundId !== false ) { throw new DBTransactionError( @@ -265,6 +274,9 @@ abstract class LBFactory implements ILBFactory { final public function commitMasterChanges( $fname = __METHOD__, array $options = [] ) { $this->assertTransactionRoundStage( self::ROUND_CURSORY ); + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + $this->trxRoundStage = self::ROUND_COMMITTING; if ( $this->trxRoundId !== false && $this->trxRoundId !== $fname ) { throw new DBTransactionError( @@ -272,8 +284,6 @@ abstract class LBFactory implements ILBFactory { "$fname: transaction round '{$this->trxRoundId}' still running" ); } - /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts // Run pre-commit callbacks and suppress post-commit callbacks, aborting on failure do { $count = 0; // number of callbacks executed this iteration @@ -299,6 +309,9 @@ abstract class LBFactory implements ILBFactory { } final public function rollbackMasterChanges( $fname = __METHOD__ ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + $this->trxRoundStage = self::ROUND_ROLLING_BACK; $this->trxRoundId = false; // Actually perform the rollback on all master DB connections and revert DBO_TRX @@ -673,6 +686,9 @@ abstract class LBFactory implements ILBFactory { } public function closeAll() { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + $this->forEachLBCallMethod( 'closeAll' ); } diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 066d4b4089..585a7822f7 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1498,6 +1498,11 @@ class LoadBalancer implements ILoadBalancer { } public function closeAll() { + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } + $fname = __METHOD__; $this->forEachOpenConnection( function ( IDatabase $conn ) use ( $fname ) { $host = $conn->getServer(); @@ -1544,6 +1549,10 @@ class LoadBalancer implements ILoadBalancer { public function finalizeMasterChanges( $fname = __METHOD__, $owner = null ) { $this->assertOwnership( $fname, $owner ); $this->assertTransactionRoundStage( [ self::ROUND_CURSORY, self::ROUND_FINALIZED ] ); + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } $this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise // Loop until callbacks stop adding callbacks on other connections @@ -1569,6 +1578,10 @@ class LoadBalancer implements ILoadBalancer { public function approveMasterChanges( array $options, $fname = __METHOD__, $owner = null ) { $this->assertOwnership( $fname, $owner ); $this->assertTransactionRoundStage( self::ROUND_FINALIZED ); + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } $limit = $options['maxWriteDuration'] ?? 0; @@ -1609,6 +1622,10 @@ class LoadBalancer implements ILoadBalancer { ); } $this->assertTransactionRoundStage( self::ROUND_CURSORY ); + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } // Clear any empty transactions (no writes/callbacks) from the implicit round $this->flushMasterSnapshots( $fname ); @@ -1628,12 +1645,13 @@ class LoadBalancer implements ILoadBalancer { public function commitMasterChanges( $fname = __METHOD__, $owner = null ) { $this->assertOwnership( $fname, $owner ); $this->assertTransactionRoundStage( self::ROUND_APPROVED ); + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } $failures = []; - /** @noinspection PhpUnusedLocalVariableInspection */ - $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts - $restore = ( $this->trxRoundId !== false ); $this->trxRoundId = false; $this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise @@ -1676,6 +1694,10 @@ class LoadBalancer implements ILoadBalancer { "Transaction should be in the callback stage (not '{$this->trxRoundStage}')" ); } + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } $oldStage = $this->trxRoundStage; $this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise @@ -1746,6 +1768,10 @@ class LoadBalancer implements ILoadBalancer { "Transaction should be in the callback stage (not '{$this->trxRoundStage}')" ); } + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } $e = null; @@ -1764,6 +1790,10 @@ class LoadBalancer implements ILoadBalancer { public function rollbackMasterChanges( $fname = __METHOD__, $owner = null ) { $this->assertOwnership( $fname, $owner ); + if ( $this->ownerId === null ) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $scope = ScopedCallback::newScopedIgnoreUserAbort(); + } $restore = ( $this->trxRoundId !== false ); $this->trxRoundId = false; -- 2.20.1