Tobias Gritschacher has submitted this change and it was merged.
Change subject: rebuildTermSearchKey should wait for slaves.
......................................................................
rebuildTermSearchKey should wait for slaves.
rebuildTermSearchKey should sleep if slaves get lagged, in order
to avoid locking the database because slaves get too far behind.
Change-Id: I9eb2735b688f80e7319c2b73c56cbf6c1ba54fcc
Note: This should be backported to the wmf12 branch.
---
M repo/includes/store/sql/TermSearchKeyBuilder.php
1 file changed, 27 insertions(+), 0 deletions(-)
Approvals:
Tobias Gritschacher: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/repo/includes/store/sql/TermSearchKeyBuilder.php
b/repo/includes/store/sql/TermSearchKeyBuilder.php
index f6e6248..5c299b4 100644
--- a/repo/includes/store/sql/TermSearchKeyBuilder.php
+++ b/repo/includes/store/sql/TermSearchKeyBuilder.php
@@ -147,6 +147,10 @@
$total = 0;
while ( true ) {
+ // Make sure we are not running too far ahead of the
slaves,
+ // as that would cause the site to be rendered read
only.
+ $this->waitForSlaves( $dbw );
+
$dbw->begin();
$terms = $dbw->select(
@@ -191,6 +195,29 @@
}
/**
+ * Wait for slaves (quietly)
+ *
+ * @todo: this should be in the Database class.
+ * @todo: thresholds should be configurable
+ *
+ * @author Tim Starling (stolen from recompressTracked.php)
+ */
+ protected function waitForSlaves() {
+ $lb = wfGetLB(); //TODO: allow foreign DB, get from $this->table
+
+ while ( true ) {
+ list( $host, $maxLag ) = $lb->getMaxLag();
+ if ( $maxLag < 2 ) {
+ break;
+ }
+
+ $this->report( "Slaves are lagged by $maxLag seconds,
sleeping..." );
+ sleep( 5 );
+ $this->report( "Resuming..." );
+ }
+ }
+
+ /**
* Updates a single row with a newley calculated search key.
* The search key is calculated using Term::normalizeText().
*
--
To view, visit https://gerrit.wikimedia.org/r/54685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9eb2735b688f80e7319c2b73c56cbf6c1ba54fcc
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Anja Jentzsch <[email protected]>
Gerrit-Reviewer: Asher <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits