*/
private $mTrxWriteDuration = 0.0;
+ /** @var array Map of (name => 1) for locks obtained via lock() */
+ private $mNamedLocksHeld = array();
+
/** @var IDatabase|null Lazy handle to the master DB this server replicates from */
private $lazyMasterHandle;
$msg = __METHOD__ . ": lost connection to $server; reconnected";
wfDebugLog( 'DBPerformance', "$msg:\n" . wfBacktrace( true ) );
- if ( $hadTrx ) {
+ if ( $hadTrx || $this->mNamedLocksHeld ) {
# Leave $ret as false and let an error be reported.
# Callers may catch the exception and continue to use the DB.
$this->reportQueryError( $lastError, $lastErrno, $sql, $fname, $tempIgnore );
}
public function lock( $lockName, $method, $timeout = 5 ) {
+ $this->mNamedLocksHeld[$lockName] = 1;
+
return true;
}
public function unlock( $lockName, $method ) {
+ unset( $this->mNamedLocksHeld[$lockName] );
+
return true;
}
$that = $this;
$unlocker = new ScopedCallback( function () use ( $that, $lockKey, $fname ) {
+ $that->commit( __METHOD__, 'flush' );
$that->unlock( $lockKey, $fname );
} );