jenkins-bot has submitted this change and it was merged.

Change subject: Made TransactionProfiler handle nested transactions to the same 
server/DB
......................................................................


Made TransactionProfiler handle nested transactions to the same server/DB

Change-Id: Ie4dfd4af88a9da76c76b21053bbd125c6ad3b193
---
M includes/db/Database.php
M includes/profiler/Profiler.php
M includes/profiler/ProfilerStub.php
3 files changed, 22 insertions(+), 14 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/Database.php b/includes/db/Database.php
index 8288e65..f7fe980 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -1054,7 +1054,8 @@
                # Keep track of whether the transaction has write queries 
pending
                if ( $this->mTrxLevel && !$this->mTrxDoneWrites && 
$this->isWriteQuery( $sql ) ) {
                        $this->mTrxDoneWrites = true;
-                       Profiler::instance()->transactionWritingIn( 
$this->mServer, $this->mDBname );
+                       $id = spl_object_hash( $this );
+                       Profiler::instance()->transactionWritingIn( 
$this->mServer, $this->mDBname, $id );
                }
 
                $queryProf = '';
@@ -3410,7 +3411,8 @@
                        $this->runOnTransactionPreCommitCallbacks();
                        $this->doCommit( $fname );
                        if ( $this->mTrxDoneWrites ) {
-                               Profiler::instance()->transactionWritingOut( 
$this->mServer, $this->mDBname );
+                               $id = spl_object_hash( $this );
+                               Profiler::instance()->transactionWritingOut( 
$this->mServer, $this->mDBname, $id );
                        }
                        $this->runOnTransactionIdleCallbacks();
                }
@@ -3476,7 +3478,8 @@
                $this->runOnTransactionPreCommitCallbacks();
                $this->doCommit( $fname );
                if ( $this->mTrxDoneWrites ) {
-                       Profiler::instance()->transactionWritingOut( 
$this->mServer, $this->mDBname );
+                       $id = spl_object_hash( $this );
+                       Profiler::instance()->transactionWritingOut( 
$this->mServer, $this->mDBname, $id );
                }
                $this->runOnTransactionIdleCallbacks();
        }
@@ -3527,7 +3530,8 @@
                $this->mTrxPreCommitCallbacks = array(); // cancel
                $this->mTrxAtomicLevels = new SplStack;
                if ( $this->mTrxDoneWrites ) {
-                       Profiler::instance()->transactionWritingOut( 
$this->mServer, $this->mDBname );
+                       $id = spl_object_hash( $this );
+                       Profiler::instance()->transactionWritingOut( 
$this->mServer, $this->mDBname, $id );
                }
        }
 
diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php
index b709498..efbdf05 100644
--- a/includes/profiler/Profiler.php
+++ b/includes/profiler/Profiler.php
@@ -205,9 +205,10 @@
         *
         * @param string $server DB server
         * @param string $db DB name
+        * @param string $id Resource ID string of connection
         */
-       public function transactionWritingIn( $server, $db ) {
-               $this->trxProfiler->transactionWritingIn( $server, $db );
+       public function transactionWritingIn( $server, $db, $id = '' ) {
+               $this->trxProfiler->transactionWritingIn( $server, $db, $id );
        }
 
        /**
@@ -219,9 +220,10 @@
         *
         * @param string $server DB server
         * @param string $db DB name
+        * @param string $id Resource ID string of connection
         */
-       public function transactionWritingOut( $server, $db ) {
-               $this->trxProfiler->transactionWritingOut( $server, $db );
+       public function transactionWritingOut( $server, $db, $id = '' ) {
+               $this->trxProfiler->transactionWritingOut( $server, $db, $id );
        }
 
        /**
@@ -366,9 +368,10 @@
         *
         * @param string $server DB server
         * @param string $db DB name
+        * @param string $id Resource ID string of connection
         */
-       public function transactionWritingIn( $server, $db ) {
-               $name = "{$server} ({$db})";
+       public function transactionWritingIn( $server, $db, $id ) {
+               $name = "{$server} ({$db}) ($id)";
                if ( isset( $this->mDBTrxHoldingLocks[$name] ) ) {
                        ++$this->mDBTrxHoldingLocks[$name]['refs'];
                } else {
@@ -412,9 +415,10 @@
         *
         * @param string $server DB server
         * @param string $db DB name
+        * @param string $id Resource ID string of connection
         */
-       public function transactionWritingOut( $server, $db ) {
-               $name = "{$server} ({$db})";
+       public function transactionWritingOut( $server, $db, $id ) {
+               $name = "{$server} ({$db}) ($id)";
                if ( --$this->mDBTrxHoldingLocks[$name]['refs'] <= 0 ) {
                        $slow = false;
                        foreach ( $this->mDBTrxMethodTimes[$name] as $info ) {
diff --git a/includes/profiler/ProfilerStub.php 
b/includes/profiler/ProfilerStub.php
index 7b310c1..6de97ba 100644
--- a/includes/profiler/ProfilerStub.php
+++ b/includes/profiler/ProfilerStub.php
@@ -39,7 +39,7 @@
        public function close() {}
        public function logData() {}
        public function getCurrentSection() { return ''; }
-       public function transactionWritingIn( $server, $db ) {}
-       public function transactionWritingOut( $server, $db ) {}
+       public function transactionWritingIn( $server, $db, $id = '' ) {}
+       public function transactionWritingOut( $server, $db, $id = '' ) {}
        public function getRawData() { return array(); }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/130813
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie4dfd4af88a9da76c76b21053bbd125c6ad3b193
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Chad <[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

Reply via email to