X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Floadbalancer%2FLoadBalancer.php;h=750df0f4c21f97c1e706cb619c75c5aff782c867;hp=35198ac37cbadf3839a302a8715829fe78664270;hb=5bad47dbb4519d6a67a2aba468fb513319311c9a;hpb=df0535e69ea260c6358317a5f0ca07d621f077bb diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 35198ac37c..750df0f4c2 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -532,7 +532,7 @@ class LoadBalancer implements ILoadBalancer { if ( $this->loads[$i] > 0 ) { $start = microtime( true ); $ok = $this->doWait( $i, true, $timeout ) && $ok; - $timeout -= ( microtime( true ) - $start ); + $timeout -= intval( microtime( true ) - $start ); if ( $timeout <= 0 ) { break; // timeout reached } @@ -1373,11 +1373,12 @@ class LoadBalancer implements ILoadBalancer { $e = null; // first exception $this->forEachOpenMasterConnection( function ( Database $conn ) use ( $type, &$e ) { $conn->setTrxEndCallbackSuppression( false ); - if ( $conn->writesOrCallbacksPending() ) { - // This happens if onTransactionIdle() callbacks leave callbacks on *another* DB - // (which finished its callbacks already). Warn and recover in this case. Let the - // callbacks run in the final commitMasterChanges() in LBFactory::shutdown(). - $this->queryLogger->info( __METHOD__ . ": found writes/callbacks pending." ); + // Callbacks run in AUTO-COMMIT mode, so make sure no transactions are pending... + if ( $conn->writesPending() ) { + // This happens if onTransactionIdle() callbacks write to *other* handles + // (which already finished their callbacks). Let any callbacks run in the final + // commitMasterChanges() in LBFactory::shutdown(), when the transaction is gone. + $this->queryLogger->warning( __METHOD__ . ": found writes pending." ); return; } elseif ( $conn->trxLevel() ) { // This happens for single-DB setups where DB_REPLICA uses the master DB, @@ -1407,9 +1408,7 @@ class LoadBalancer implements ILoadBalancer { $this->trxRoundId = false; $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( $fname, $restore ) { - if ( $conn->writesOrCallbacksPending() || $conn->explicitTrxActive() ) { - $conn->rollback( $fname, $conn::FLUSHING_ALL_PEERS ); - } + $conn->rollback( $fname, $conn::FLUSHING_ALL_PEERS ); if ( $restore ) { $this->undoTransactionRoundFlags( $conn ); }