Original query:

create table queue (id int generated always as identity, batch_id int not null);

insert into queue (batch_id) values (1),(1),(2);

select * from queue;

-- backend 1:

BEGIN;
select * from queue order by batch_id fetch first row with ties for update skip locked;

-- returns batch_id 1

-- backend 2:

BEGIN;
select * from queue order by batch_id fetch first row with ties for update skip locked;

-- nothing, not batch 2