- DeferredUpdates::addUpdate(
- new AutoCommitUpdate(
- $this->getMasterDB(),
- __METHOD__,
- function ( IDatabase $dbw, $fname ) use ( $jobs, $flags ) {
- $this->doBatchPushInternal( $dbw, $jobs, $flags, $fname );
- }
- ),
- DeferredUpdates::PRESEND
+ $dbw = $this->getMasterDB();
+ // In general, there will be two cases here:
+ // a) sqlite; DB connection is probably a regular round-aware handle.
+ // If the connection is busy with a transaction, then defer the job writes
+ // until right before the main round commit step. Any errors that bubble
+ // up will rollback the main commit round.
+ // b) mysql/postgres; DB connection is generally a separate CONN_TRX_AUTO handle.
+ // No transaction is active nor will be started by writes, so enqueue the jobs
+ // now so that any errors will show up immediately as the interface expects. Any
+ // errors that bubble up will rollback the main commit round.
+ $fname = __METHOD__;
+ $dbw->onTransactionPreCommitOrIdle(
+ function () use ( $dbw, $jobs, $flags, $fname ) {
+ $this->doBatchPushInternal( $dbw, $jobs, $flags, $fname );
+ },
+ $fname