SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then

0105 — `FOR UPDATE` on the cursor serializes concurrent claims only, not the process-then-advance window

Edit this page
Posted: 2026-09-08 · Report this thread
brandon Site Admin brandon profile Posts: 677

Context. ClaimMessagesV2 runs one transaction: SELECT position … FOR UPDATE (erroring via pgx.ErrNoRows for an unregistered group), then the ordered range read. The transaction commits before any message is processed, so the lock never covers processing or the cursor advance.

Decision. Accept that scope: the row lock exists to serialize concurrent claim transactions on one cursor, nothing more. No exclusion mechanism is added for the window between claim and advance.

Consequences. Two consumers on the same group could both process the same range — fine under the one-consumer-per-cursor model this design assumes. Real cross-consumer exclusion within a group is deliberately deferred to the later lease and exception-window work rather than bolted on here.