- $limit = isset( $options['maxWriteDuration'] ) ? $options['maxWriteDuration'] : 0;
-
- // Run pre-commit callbacks to keep them out of the COMMIT step. If one errors out here
- // then all DB transactions can be rolled back before anything was committed yet.
- $this->forEachLBCallMethod( 'runPreCommitCallbacks' );
-
- $this->logMultiDbTransaction();
- $this->forEachLB( function ( LoadBalancer $lb ) use ( $limit ) {
- $lb->forEachOpenConnection( function ( IDatabase $db ) use ( $limit ) {
- $time = $db->pendingWriteQueryDuration();
- if ( $limit > 0 && $time > $limit ) {
- throw new DBTransactionError(
- $db,
- wfMessage( 'transaction-duration-limit-exceeded', $time, $limit )->text()
- );
- }
- } );
- } );
-
+ // Perform all pre-commit callbacks, aborting on failure
+ $this->forEachLBCallMethod( 'runMasterPreCommitCallbacks' );
+ // Perform all pre-commit checks, aborting on failure
+ $this->forEachLBCallMethod( 'approveMasterChanges', [ $options ] );
+ // Log the DBs and methods involved in multi-DB transactions
+ $this->logIfMultiDbTransaction();
+ // Actually perform the commit on all master DB connections
+ $this->forEachLBCallMethod( 'commitMasterChanges', [ $fname ] );
+ // Run all post-commit callbacks
+ $this->forEachLBCallMethod( 'runMasterPostCommitCallbacks' );
+ // Commit any dangling DBO_TRX transactions from callbacks on one DB to another DB