*/
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();
}
if ( $flush !== 'flush' ) {
if ( !$this->mTrxLevel ) {
wfWarn( "$fname: No transaction to rollback, something got out of sync!" );
+ return; // nothing to do
} elseif ( $this->mTrxAutomatic ) {
wfWarn( "$fname: Explicit rollback of implicit transaction. Something may be out of sync!" );
}
$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 );
}
}