diff options
author | Tim Starling <tstarling@wikimedia.org> | 2022-01-13 12:49:29 +1100 |
---|---|---|
committer | Tim Starling <tstarling@wikimedia.org> | 2022-01-13 02:08:40 +0000 |
commit | e0160e2352c5c0336ad08c38e8fb7fd744a36d6e (patch) | |
tree | 26b8246f9742d0919f5cde0a122816d85f700ab0 | |
parent | 5b4a658ccd69d652577e346cee186f8cba99158d (diff) |
maintenance: Add --batch-size to sql.php
Wait for replication after each batch of queries in sql.php, instead of
only at the end.
Bug: T299095
Change-Id: Ie077e9cec66cb35e2339982638151aa8edd06dc4
-rw-r--r-- | maintenance/sql.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/maintenance/sql.php b/maintenance/sql.php index 6d1fcfa3dfd8..4ee9792eb3e1 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -49,6 +49,7 @@ class MwSql extends Maintenance { 'The database wiki ID to use if not the current one', false, true ); $this->addOption( 'replicadb', 'Replica DB server to use instead of the primary DB (can be "any")', false, true ); + $this->setBatchSize( 100 ); } public function execute() { @@ -132,6 +133,7 @@ class MwSql extends Maintenance { $prompt = $newPrompt; $doDie = !Maintenance::posix_isatty( 0 ); $res = 1; + $batchCount = 0; while ( ( $line = Maintenance::readconsole( $prompt ) ) !== false ) { if ( !$line ) { # User simply pressed return key @@ -154,6 +156,10 @@ class MwSql extends Maintenance { } // @phan-suppress-next-line SecurityCheck-SQLInjection $res = $this->sqlDoQuery( $db, $wholeLine, $doDie ); + if ( $this->getBatchSize() && ++$batchCount >= $this->getBatchSize() ) { + $batchCount = 0; + $lbFactory->waitForReplication(); + } $prompt = $newPrompt; $wholeLine = ''; } |