Hoo man has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386463 )

Change subject: Use very large insert batches and wait in EntityUsageTable
......................................................................

Use very large insert batches and wait in EntityUsageTable

Per Jaime's suggestion.

Change-Id: I6089ff695a50a284db59f09ff4889c9cb31664e6
---
M client/includes/Usage/Sql/EntityUsageTable.php
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/63/386463/1

diff --git a/client/includes/Usage/Sql/EntityUsageTable.php 
b/client/includes/Usage/Sql/EntityUsageTable.php
index c555d8e..09825ce 100644
--- a/client/includes/Usage/Sql/EntityUsageTable.php
+++ b/client/includes/Usage/Sql/EntityUsageTable.php
@@ -13,6 +13,7 @@
 use Wikibase\DataModel\Entity\EntityIdParser;
 use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\DBUnexpectedError;
+use Wikimedia\Rdbms\LoadBalancer;
 
 /**
  * Helper class for updating the wbc_entity_usage table.
@@ -41,6 +42,11 @@
         * @var Database
         */
        private $readConnection;
+
+       /**
+        * @var LoadBalancer
+        */
+       private $loadBalancer;
 
        /**
         * @var string
@@ -80,8 +86,8 @@
                $this->tableName = $tableName ?: self::DEFAULT_TABLE_NAME;
 
                //TODO: Inject
-               $this->readConnection = 
MediaWikiServices::getInstance()->getDBLoadBalancer()
-                       ->getConnection( DB_REPLICA );
+               $this->loadBalancer = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
+               $this->readConnection = $this->loadBalancer->getConnection( 
DB_REPLICA );
        }
 
        /**
@@ -160,7 +166,7 @@
 
                $batches = array_chunk(
                        $this->makeUsageRows( $pageId, $usages ),
-                       $this->batchSize
+                       $this->batchSize * 5 // This is supposed to be done in 
huge batches, per the DBA.
                );
 
                $c = 0;
@@ -173,6 +179,7 @@
                }
 
                $this->writeConnection->endAtomic( __METHOD__ );
+               $this->loadBalancer->waitForAll( 
$this->writeConnection->getMasterPos() );
 
                return $c;
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6089ff695a50a284db59f09ff4889c9cb31664e6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>

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

Reply via email to