/** @var DatabaseDomain Local DB domain ID and default for selectDB() calls */
private $localDomain;
- /** @var Database[][][] Map of (connection category => server index => IDatabase[]) */
+ /**
+ * @var IDatabase[][][]|Database[][][] Map of (connection category => server index => IDatabase[])
+ */
private $conns;
/** @var array[] Map of (server index => server config array) */
private $tableAliases = [];
/** @var string[] Map of (index alias => index) */
private $indexAliases = [];
- /** @var array[] Map of (name => callable) */
+ /** @var callable[] Map of (name => callable) */
private $trxRecurringCallbacks = [];
/** @var bool[] Map of (domain => whether to use "temp tables only" mode) */
private $tempTablesOnlyMode = [];
$serverIndex = $conn->getLBInfo( 'serverIndex' );
$refCount = $conn->getLBInfo( 'foreignPoolRefCount' );
if ( $serverIndex === null || $refCount === null ) {
- /**
- * This can happen in code like:
- * foreach ( $dbs as $db ) {
- * $conn = $lb->getConnection( $lb::DB_REPLICA, [], $db );
- * ...
- * $lb->reuseConnection( $conn );
- * }
- * When a connection to the local DB is opened in this way, reuseConnection()
- * should be ignored
- */
- return;
+ return; // non-foreign connection; no domain-use tracking to update
} elseif ( $conn instanceof DBConnRef ) {
// DBConnRef already handles calling reuseConnection() and only passes the live
// Database instance to this method. Any caller passing in a DBConnRef is broken.
}
public function closeAll() {
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
+
$fname = __METHOD__;
$this->forEachOpenConnection( function ( IDatabase $conn ) use ( $fname ) {
$host = $conn->getServer();
public function finalizeMasterChanges( $fname = __METHOD__, $owner = null ) {
$this->assertOwnership( $fname, $owner );
$this->assertTransactionRoundStage( [ self::ROUND_CURSORY, self::ROUND_FINALIZED ] );
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
// Loop until callbacks stop adding callbacks on other connections
public function approveMasterChanges( array $options, $fname = __METHOD__, $owner = null ) {
$this->assertOwnership( $fname, $owner );
$this->assertTransactionRoundStage( self::ROUND_FINALIZED );
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
$limit = $options['maxWriteDuration'] ?? 0;
);
}
$this->assertTransactionRoundStage( self::ROUND_CURSORY );
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
// Clear any empty transactions (no writes/callbacks) from the implicit round
$this->flushMasterSnapshots( $fname );
public function commitMasterChanges( $fname = __METHOD__, $owner = null ) {
$this->assertOwnership( $fname, $owner );
$this->assertTransactionRoundStage( self::ROUND_APPROVED );
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
$failures = [];
- /** @noinspection PhpUnusedLocalVariableInspection */
- $scope = ScopedCallback::newScopedIgnoreUserAbort(); // try to ignore client aborts
-
$restore = ( $this->trxRoundId !== false );
$this->trxRoundId = false;
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
"Transaction should be in the callback stage (not '{$this->trxRoundStage}')"
);
}
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
$oldStage = $this->trxRoundStage;
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
"Transaction should be in the callback stage (not '{$this->trxRoundStage}')"
);
}
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
$e = null;
public function rollbackMasterChanges( $fname = __METHOD__, $owner = null ) {
$this->assertOwnership( $fname, $owner );
+ if ( $this->ownerId === null ) {
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = ScopedCallback::newScopedIgnoreUserAbort();
+ }
$restore = ( $this->trxRoundId !== false );
$this->trxRoundId = false;