*/
protected $mTrxLevel = 0;
+ /**
+ * Either a short hexidecimal string if a transaction is active or ""
+ *
+ * @var string
+ */
+ protected $mTrxShortId = '';
+
/**
* Remembers the function name given for starting the most recent transaction via begin().
* Used to provide additional context for error reporting.
# Keep track of whether the transaction has write queries pending
if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $this->isWriteQuery( $sql ) ) {
$this->mTrxDoneWrites = true;
- $id = spl_object_hash( $this );
- Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname, $id );
+ Profiler::instance()->transactionWritingIn(
+ $this->mServer, $this->mDBname, $this->mTrxShortId );
}
$queryProf = '';
$queryProf = 'query: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 );
$totalProf = 'DatabaseBase::query';
}
+ # Include query transaction state
+ $queryProf .= $this->mTrxShortId ? " [TRX#{$this->mTrxShortId}]" : "";
+
+ $trx = $this->mTrxLevel ? 'TRX=yes' : 'TRX=no';
wfProfileIn( $totalProf );
wfProfileIn( $queryProf );
}
$this->runOnTransactionPreCommitCallbacks();
$this->doCommit( $fname );
if ( $this->mTrxDoneWrites ) {
- $id = spl_object_hash( $this );
- Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname, $id );
+ Profiler::instance()->transactionWritingOut(
+ $this->mServer, $this->mDBname, $this->mTrxShortId );
}
$this->runOnTransactionIdleCallbacks();
}
$this->mTrxAtomicLevels = new SplStack;
$this->mTrxIdleCallbacks = array();
$this->mTrxPreCommitCallbacks = array();
+ $this->mTrxShortId = wfRandomString( 12 );
}
/**
$this->runOnTransactionPreCommitCallbacks();
$this->doCommit( $fname );
if ( $this->mTrxDoneWrites ) {
- $id = spl_object_hash( $this );
- Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname, $id );
+ Profiler::instance()->transactionWritingOut(
+ $this->mServer, $this->mDBname, $this->mTrxShortId );
}
$this->runOnTransactionIdleCallbacks();
}
$this->mTrxPreCommitCallbacks = array(); // cancel
$this->mTrxAtomicLevels = new SplStack;
if ( $this->mTrxDoneWrites ) {
- $id = spl_object_hash( $this );
- Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname, $id );
+ Profiler::instance()->transactionWritingOut(
+ $this->mServer, $this->mDBname, $this->mTrxShortId );
}
}
*
* @param string $server DB server
* @param string $db DB name
- * @param string $id Resource ID string of connection
+ * @param string $id ID string of transaction
*/
public function transactionWritingIn( $server, $db, $id ) {
- $name = "{$server} ({$db}) ($id)";
+ $name = "{$server} ({$db}) (TRX#$id)";
if ( isset( $this->mDBTrxHoldingLocks[$name] ) ) {
++$this->mDBTrxHoldingLocks[$name]['refs'];
} else {
*
* @param string $server DB server
* @param string $db DB name
- * @param string $id Resource ID string of connection
+ * @param string $id ID string of transaction
*/
public function transactionWritingOut( $server, $db, $id ) {
- $name = "{$server} ({$db}) ($id)";
+ $name = "{$server} ({$db}) (TRX#$id)";
if ( --$this->mDBTrxHoldingLocks[$name]['refs'] <= 0 ) {
$slow = false;
foreach ( $this->mDBTrxMethodTimes[$name] as $info ) {