From: Aaron Schulz Date: Thu, 31 Dec 2015 23:30:16 +0000 (-0800) Subject: Make Maintenance::commitTransaction() do slave wait checks X-Git-Tag: 1.31.0-rc.0~8440^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=ff1c845082dc85b21f35f7a1a665e35fcd6c062c;p=lhc%2Fweb%2Fwiklou.git Make Maintenance::commitTransaction() do slave wait checks This makes it less likely to be forgotten in scripts. Change-Id: I9b939dcda8d6191a2a5ee3b3b50d2ec950dc0402 --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index e90812d28e..291920b415 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -109,6 +109,9 @@ abstract class Maintenance { */ private $mDb = null; + /** @var float UNIX timestamp */ + private $lastSlaveWait = 0.0; + /** * Used when creating separate schema files. * @var resource @@ -1178,21 +1181,27 @@ abstract class Maintenance { } /** - * Commit a transcation on a DB + * Commit the transcation on a DB handle and wait for slaves to catch up * * This method makes it clear that commit() is called from a maintenance script, * which has outermost scope. This is safe, unlike $dbw->commit() called in other places. * * @param IDatabase $dbw * @param string $fname Caller name + * @return bool Whether the slave wait succeeded * @since 1.27 */ protected function commitTransaction( IDatabase $dbw, $fname ) { $dbw->commit( $fname ); + + $ok = wfWaitForSlaves( $this->lastSlaveWait, false, '*', 30 ); + $this->lastSlaveWait = microtime( true ); + + return $ok; } /** - * Rollback a transcation on a DB + * Rollback the transcation on a DB handle * * This method makes it clear that rollback() is called from a maintenance script, * which has outermost scope. This is safe, unlike $dbw->rollback() called in other places.