From 703b0691caf0cb5c29ede148c1a9f14c529cf8a1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 11 Sep 2016 15:51:15 -0700 Subject: [PATCH] Use ESTIMATE_DB_APPLY for total transaction time estimate Individual write queries already do this, but the COMMIT step still used the old accounting. Change-Id: I416a524d6652f933cbc49033b49745db732c8b92 --- includes/db/Database.php | 2 +- includes/jobqueue/JobRunner.php | 3 ++- tests/phpunit/includes/db/DatabaseTestHelper.php | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index ced7379084..eca80d85cd 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -2971,7 +2971,7 @@ abstract class DatabaseBase implements IDatabase { $this->assertOpen(); $this->runOnTransactionPreCommitCallbacks(); - $writeTime = $this->pendingWriteQueryDuration(); + $writeTime = $this->pendingWriteQueryDuration( self::ESTIMATE_DB_APPLY ); $this->doCommit( $fname ); if ( $this->mTrxDoneWrites ) { $this->mDoneWrites = microtime( true ); diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 570d6dbd32..022abd9f0b 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -504,6 +504,7 @@ class JobRunner implements LoggerAwareInterface { private function commitMasterChanges( LBFactory $lbFactory, Job $job, $fnameTrxOwner ) { global $wgJobSerialCommitThreshold; + $time = false; $lb = $lbFactory->getMainLB( wfWikiID() ); if ( $wgJobSerialCommitThreshold !== false && $lb->getServerCount() > 1 ) { // Generally, there is one master connection to the local DB @@ -527,7 +528,7 @@ class JobRunner implements LoggerAwareInterface { return; } - $ms = intval( 1000 * $dbwSerial->pendingWriteQueryDuration() ); + $ms = intval( 1000 * $time ); $msg = $job->toString() . " COMMIT ENQUEUED [{$ms}ms of writes]"; $this->logger->info( $msg ); $this->debugCallback( $msg ); diff --git a/tests/phpunit/includes/db/DatabaseTestHelper.php b/tests/phpunit/includes/db/DatabaseTestHelper.php index 33ccb4d201..63322cc9a2 100644 --- a/tests/phpunit/includes/db/DatabaseTestHelper.php +++ b/tests/phpunit/includes/db/DatabaseTestHelper.php @@ -174,6 +174,11 @@ class DatabaseTestHelper extends DatabaseBase { return true; } + function ping( &$rtt = null ) { + $rtt = 0.0; + return true; + } + protected function closeConnection() { return false; } -- 2.20.1