Skip to content

fix(sqlite): a pop takes a message from the queue polled only - #1871

Merged
v1r3n merged 2 commits into
mainfrom
fix/sqlite-queue-pop-scope
Nov 24, 2026
Merged

v1r3n merged 2 commits into
mainfrom
fix/sqlite-queue-pop-scope

Conversation

@mp-orkes

Copy link
Copy Markdown
Contributor

Why

In the SQLite queue, a message id is unique within one queue. The same id can be in two queues at the same time.

SqliteQueueDAO.pop selected the ids from the polled queue, but its UPDATE matched on the id only. The pop thus marked and returned the rows with those ids in all queues. A message with the same id in a second queue was taken from that queue too, and the caller got the id two times.

What changed

  • The pop of the SQLite queue takes messages from the polled queue only. A message with the same id in a different queue stays there until a pop of that queue takes it.

Notes

  • The UPDATE now names the queue: WHERE queue_name = ? AND message_id IN (...).
  • The Postgres and MySQL pops already name the queue in the UPDATE. They do not change.
  • No known code path on main puts one id in two queues. The native workflows PR (#1832) does, so this fix must merge before it.
  • The commit is cherry-picked from #1832. Its message and the comment of the new test refer to native workflows for that reason.

🤖 Generated with Claude Code

The pop chose ids in the queue polled but marked and returned every row
with those ids, in any queue. A message id is unique within a queue, not
across queues: a native continuation offered on a worker's own queue and,
as a fallback, on the shared queue under the same id was popped from both
and run twice. The update now names the queue too.
@mp-orkes
mp-orkes marked this pull request as ready for review November 24, 2026 01:06
@v1r3n
v1r3n merged commit 1700c3a into main Nov 24, 2026
6 checks passed
@v1r3n
v1r3n deleted the fix/sqlite-queue-pop-scope branch November 24, 2026 05:09
This was referenced Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants