This increases the odds of seeing newer data and not guessing a
wrong revision ID due to getting raced out between stash and save.
Change-Id: Icf0f9b9c4d559f4ddf05a4ca8679e3c4dca5620a
: DB_REPLICA; // T154554
$edit->popts->setSpeculativeRevIdCallback( function () use ( $dbIndex ) {
- return 1 + (int)wfGetDB( $dbIndex )->selectField(
+ $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
+ // Use a fresh connection in order to see the latest data, by avoiding
+ // stale data from REPEATABLE-READ snapshots.
+ $db = $lb->getConnectionRef( $dbIndex, [], false, $lb::CONN_TRX_AUTO );
+
+ return 1 + (int)$db->selectField(
'revision',
'MAX(rev_id)',
[],