Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/54685
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, 25 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/85/54685/1
diff --git a/repo/includes/store/sql/TermSearchKeyBuilder.php
b/repo/includes/store/sql/TermSearchKeyBuilder.php
index f6e6248..2cdfef6 100644
--- a/repo/includes/store/sql/TermSearchKeyBuilder.php
+++ b/repo/includes/store/sql/TermSearchKeyBuilder.php
@@ -184,6 +184,8 @@
if ( $c < $this->batchSize ) {
// we are done.
break;
+ } else {
+ $this->waitForSlaves( $dbw );
}
}
@@ -191,6 +193,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: newchange
Gerrit-Change-Id: I9eb2735b688f80e7319c2b73c56cbf6c1ba54fcc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits