jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383384 )

Change subject: Quick fix for flooding of the RC table
......................................................................


Quick fix for flooding of the RC table

Under some conditions, Wikibase can trigger a very large number (millions)
of recentchanges rows to be inserted as the result of a single edit. These
inserts are batched according to the recentChangesBatchSize setting.

This patch aborts the injection after the first batch, to mittigate
the problem of flooding the RC table. This is not a permanent solution,
please refer to T177707 for discussion. One possible refinement would be
to inject RC records only for the pages with the most watchers.

Bug: T177707
Change-Id: I0162cbfd6db3ef147745d281a7568313e998f0c3
---
M client/includes/Changes/WikiPageUpdater.php
M client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
2 files changed, 15 insertions(+), 7 deletions(-)

Approvals:
  Ladsgroup: Looks good to me, approved
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, but someone else must approve



diff --git a/client/includes/Changes/WikiPageUpdater.php 
b/client/includes/Changes/WikiPageUpdater.php
index f637c25..70b9659 100644
--- a/client/includes/Changes/WikiPageUpdater.php
+++ b/client/includes/Changes/WikiPageUpdater.php
@@ -223,6 +223,7 @@
 
                $jobs = [];
                $titleBatches = array_chunk( $titles, $this->rcBatchSize );
+               $titleCount = 0;
 
                /* @var Title[] $batch */
                foreach ( $titleBatches as $batch ) {
@@ -230,11 +231,16 @@
                                . count( $batch ) . " titles" );
 
                        $jobs[] = InjectRCRecordsJob::makeJobSpecification( 
$batch, $change, $rootJobParams );
+                       $titleCount += count( $batch );
+
+                       // FIXME: This is a hot fix for T177707, and must be 
reconsidered.
+                       break;
                }
 
                $this->jobQueueGroup->lazyPush( $jobs );
+
                $this->incrementStats( 'InjectRCRecords.jobs', count( $jobs ) );
-               $this->incrementStats( 'InjectRCRecords.titles', count( $titles 
) );
+               $this->incrementStats( 'InjectRCRecords.titles', $titleCount );
        }
 
 }
diff --git a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php 
b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
index 6137192..97b9df1 100644
--- a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
+++ b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
@@ -276,8 +276,9 @@
                        $this->getLBFactoryMock(),
                        $this->getRCDupeDetectorMock(),
                        $this->getStatsdDataFactoryMock( [
-                               'InjectRCRecords.jobs' => 2, // 2 batches 
(batch size 2, 3 titles)
-                               'InjectRCRecords.titles' => 3,
+                               // FIXME: Because of the hot fix for T177707 we 
expect only the first batch.
+                               'InjectRCRecords.jobs' => 1,
+                               'InjectRCRecords.titles' => 2,
                        ] )
                );
                $updater->setRecentChangesBatchSize( 2 );
@@ -288,10 +289,11 @@
                        [ 'rootJobTimestamp' => '20202211060708', 
'rootJobSignature' => 'Kittens!', ]
                );
 
-               $this->assertEquals( [ 21, 22, 23 ], array_keys( $pages ) );
-               $this->assertEquals( [ 0, 'Foo' ], $pages[21], '$pages[21]' );
-               $this->assertEquals( [ 0, 'Bar' ], $pages[22], '$pages[22]' );
-               $this->assertEquals( [ 0, 'Cuzz' ], $pages[23], '$pages[23]' );
+               // FIXME: Because of the hot fix for T177707 we expect only the 
first batch.
+               $this->assertSame( [
+                       21 => [ 0, 'Foo' ],
+                       22 => [ 0, 'Bar' ],
+               ], $pages );
 
                $this->assertEquals(
                        [

-- 
To view, visit https://gerrit.wikimedia.org/r/383384
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0162cbfd6db3ef147745d281a7568313e998f0c3
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jcrespo <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Lydia Pintscher (WMDE) <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to