SqlIdGenerator and UpsertSqlIdGenerator have some code that’s supposed to retry acquiring an ID if a database query failed:
$success = $database->newUpdateQueryBuilder() ->update( 'wb_id_counters' ) ->set( [ 'id_value' => $id ] ) ->where( [ 'id_type' => $type ] ) ->caller( __METHOD__ )->execute(); // ...or... $success = $database->insert( 'wb_id_counters', [ 'id_value' => $id, 'id_type' => $type, ], __METHOD__ ); // Retry once, since a race condition on initial insert can cause one to fail. // Race condition is possible due to occurrence of phantom reads is possible // at non serializable transaction isolation level. if ( !$success && $retry ) { $id = $this->generateNewId( $database, $type, false ); $success = true; }
However, IDatabase::update() (or UpdateQueryBuilder::execute()), IDatabase::insert() and IDatabase::upsert() no longer return a success boolean: they either return true or throw an exception, and that’s been the case for years now (at least since rdbms: clean up return values of IDatabase write methods, though it’s not completely clear to me if that introduced the change or not).
We should either make the retry code work correctly again (by catching DB errors that previously would’ve returned false? but that’s discouraged…), or just remove it (on the basis that, apparently, nobody has had an issue with it being broken for years).