jenkins-bot has submitted this change and it was merged. Change subject: Wait for slaves in BulkSubscriptionUpdater ......................................................................
Wait for slaves in BulkSubscriptionUpdater especially needed for the purge subscriptions option Change-Id: I0babedaa0fb0cef1e1cf1ae5c526854d078da7bd (cherry picked from commit 434f1a92bbcd0b586a3e695daac5a6179c39d560) --- M client/includes/store/sql/BulkSubscriptionUpdater.php M client/maintenance/updateSubscriptions.php M client/tests/phpunit/includes/store/sql/BulkSubscriptionUpdaterTest.php 3 files changed, 22 insertions(+), 0 deletions(-) Approvals: Aude: Looks good to me, approved jenkins-bot: Verified diff --git a/client/includes/store/sql/BulkSubscriptionUpdater.php b/client/includes/store/sql/BulkSubscriptionUpdater.php index c85fb93..e48105d 100644 --- a/client/includes/store/sql/BulkSubscriptionUpdater.php +++ b/client/includes/store/sql/BulkSubscriptionUpdater.php @@ -36,6 +36,13 @@ private $subscriberWikiId; /** + * @var string|false The repo wiki's id, as used by the LoadBalancer. Used for wait for slaves. + * False indicates to use the local wiki's database, and is the default + * for the repoWiki setting. + */ + private $repoWiki; + + /** * @var int */ private $batchSize; @@ -57,6 +64,9 @@ * connections to the repo. * @param string $subscriberWikiId The local wiki's global ID, to be used as the subscriber ID * in the repo's subscription table. + * @param string|false $repoWiki The repo wiki's id, as used by the LoadBalancer. + * False (default of the repoWiki setting) indicates to + * use local wiki database. * @param int $batchSize * * @throws InvalidArgumentException @@ -65,10 +75,15 @@ ConsistentReadConnectionManager $localConnectionManager, ConsistentReadConnectionManager $repoConnectionManager, $subscriberWikiId, + $repoWiki, $batchSize = 1000 ) { if ( !is_string( $subscriberWikiId ) ) { throw new InvalidArgumentException( '$subscriberWikiId must be a string' ); + } + + if ( !is_string( $repoWiki ) && $repoWiki !== false ) { + throw new InvalidArgumentException( '$repoWiki must be a string or false' ); } if ( !is_int( $batchSize ) || $batchSize < 1 ) { @@ -79,6 +94,7 @@ $this->repoConnectionManager = $repoConnectionManager; $this->subscriberWikiId = $subscriberWikiId; + $this->repoWiki = $repoWiki; $this->batchSize = $batchSize; $this->exceptionHandler = new LogWarningExceptionHandler(); @@ -124,6 +140,8 @@ $continuation = $startEntity === null ? null : array( $startEntity->getSerialization() ); while ( true ) { + wfWaitForSlaves( null, $this->repoWiki ); + $count = $this->processUpdateBatch( $continuation ); if ( $count > 0 ) { @@ -263,6 +281,8 @@ $this->repoConnectionManager->forceMaster(); while ( true ) { + wfWaitForSlaves( null, $this->repoWiki ); + $count = $this->processDeletionBatch( $continuation ); if ( $count > 0 ) { diff --git a/client/maintenance/updateSubscriptions.php b/client/maintenance/updateSubscriptions.php index 31455dd..0c36dbe 100644 --- a/client/maintenance/updateSubscriptions.php +++ b/client/maintenance/updateSubscriptions.php @@ -61,6 +61,7 @@ new ConsistentReadConnectionManager( wfGetLB() ), new ConsistentReadConnectionManager( wfGetLB( $repoDB ), $repoDB ), $clientId, + $repoDB, $this->mBatchSize ); diff --git a/client/tests/phpunit/includes/store/sql/BulkSubscriptionUpdaterTest.php b/client/tests/phpunit/includes/store/sql/BulkSubscriptionUpdaterTest.php index 743c754..49d72a9 100644 --- a/client/tests/phpunit/includes/store/sql/BulkSubscriptionUpdaterTest.php +++ b/client/tests/phpunit/includes/store/sql/BulkSubscriptionUpdaterTest.php @@ -53,6 +53,7 @@ new ConsistentReadConnectionManager( $loadBalancer, false ), new ConsistentReadConnectionManager( $loadBalancer, false ), 'testwiki', + false, $batchSize ); } -- To view, visit https://gerrit.wikimedia.org/r/210672 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0babedaa0fb0cef1e1cf1ae5c526854d078da7bd Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: wmf/1.26wmf4 Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits