jenkins-bot has submitted this change and it was merged.
Change subject: Added a simple pendingWriteQueryDuration() DB method
......................................................................
Added a simple pendingWriteQueryDuration() DB method
Change-Id: I924cf78d8bb96d526a7ba7444f0532d7eb223bf2
---
M includes/db/Database.php
1 file changed, 26 insertions(+), 0 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/db/Database.php b/includes/db/Database.php
index 0bef28a..8c1ebf9 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -142,6 +142,13 @@
private $mTrxAutomaticAtomic = false;
/**
+ * Track the seconds spent in write queries for the current transaction
+ *
+ * @var float
+ */
+ private $mTrxWriteDuration = 0.0;
+
+ /**
* @since 1.21
* @var resource File handle for upgrade
*/
@@ -471,6 +478,18 @@
return $this->mTrxLevel && (
$this->mTrxDoneWrites || $this->mTrxIdleCallbacks ||
$this->mTrxPreCommitCallbacks
);
+ }
+
+ /**
+ * Get the time spend running write queries for this
+ *
+ * High times could be due to scanning, updates, locking, and such
+ *
+ * @return float|bool Returns false if not transaction is active
+ * @since 1.26
+ */
+ public function pendingWriteQueryDuration() {
+ return $this->mTrxLevel ? $this->mTrxWriteDuration : false;
}
/**
@@ -1160,6 +1179,7 @@
# Do the query and handle errors
$startTime = microtime( true );
$ret = $this->doQuery( $commentedSql );
+ $queryRuntime = microtime( true ) - $startTime;
# Log the query time and feed it into the DB trx profiler
$this->getTransactionProfiler()->recordQueryCompletion(
$queryProf, $startTime, $isWriteQuery,
$this->affectedRows() );
@@ -1191,6 +1211,7 @@
# Should be safe to silently retry (no
trx and thus no callbacks)
$startTime = microtime( true );
$ret = $this->doQuery( $commentedSql );
+ $queryRuntime = microtime( true ) -
$startTime;
# Log the query time and feed it into
the DB trx profiler
$this->getTransactionProfiler()->recordQueryCompletion(
$queryProf, $startTime,
$isWriteQuery, $this->affectedRows() );
@@ -1210,6 +1231,10 @@
// Destroy profile sections in the opposite order to their
creation
$queryProfSection = false;
$totalProfSection = false;
+
+ if ( $isWriteQuery && $this->mTrxLevel ) {
+ $this->mTrxWriteDuration += $queryRuntime;
+ }
return $res;
}
@@ -3633,6 +3658,7 @@
$this->mTrxIdleCallbacks = array();
$this->mTrxPreCommitCallbacks = array();
$this->mTrxShortId = wfRandomString( 12 );
+ $this->mTrxWriteDuration = 0.0;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/205998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I924cf78d8bb96d526a7ba7444f0532d7eb223bf2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits