Merge "Log startAtomic()/endAtomic() to the query logger"

This commit is contained in:
jenkins-bot 2018-10-13 01:45:09 +00:00 committed by Gerrit Code Review
commit b6fecdf6fe

View file

@ -3684,6 +3684,8 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
$sectionId = new AtomicSectionIdentifier;
$this->trxAtomicLevels[] = [ $fname, $sectionId, $savepointId ];
$this->queryLogger->debug( 'startAtomic: entering level ' .
( count( $this->trxAtomicLevels ) - 1 ) . " ($fname)" );
return $sectionId;
}
@ -3696,6 +3698,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
// Check if the current section matches $fname
$pos = count( $this->trxAtomicLevels ) - 1;
list( $savedFname, $sectionId, $savepointId ) = $this->trxAtomicLevels[$pos];
$this->queryLogger->debug( "endAtomic: leaving level $pos ($fname)" );
if ( $savedFname !== $fname ) {
throw new DBUnexpectedError(
@ -3728,6 +3731,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
throw new DBUnexpectedError( $this, "No atomic section is open (got $fname)." );
}
$excisedFnames = [];
if ( $sectionId !== null ) {
// Find the (last) section with the given $sectionId
$pos = -1;
@ -3743,6 +3747,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
$excisedIds = [];
$len = count( $this->trxAtomicLevels );
for ( $i = $pos + 1; $i < $len; ++$i ) {
$excisedFnames[] = $this->trxAtomicLevels[$i][0];
$excisedIds[] = $this->trxAtomicLevels[$i][1];
}
$this->trxAtomicLevels = array_slice( $this->trxAtomicLevels, 0, $pos + 1 );
@ -3753,6 +3758,13 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
$pos = count( $this->trxAtomicLevels ) - 1;
list( $savedFname, $savedSectionId, $savepointId ) = $this->trxAtomicLevels[$pos];
if ( $excisedFnames ) {
$this->queryLogger->debug( "cancelAtomic: canceling level $pos ($savedFname) " .
"and descendants " . implode( ', ', $excisedFnames ) );
} else {
$this->queryLogger->debug( "cancelAtomic: canceling level $pos ($savedFname)" );
}
if ( $savedFname !== $fname ) {
throw new DBUnexpectedError(
$this,