Skip to content

Add commit (poll -> process -> commit) to queue/v1 - #439

Merged
em3s merged 1 commit into
mainfrom
feat/queue-eviction
Jul 21, 2026
Merged

em3s merged 1 commit into
mainfrom
feat/queue-eviction

Conversation

@em3s

@em3s em3s commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add commit to queue/v1: a consumer polls a partition, processes the batch, then commits up to that batch's offset — every message with seq <= offset is deleted. DELETE /queue/v1/namespaces/{ns}/queues/{queue}/partitions/{partition}/messages?offset=X.

This completes the poll → process → commit lifecycle and doubles as retention/eviction. An immutable edge keeps no per-message ack state, so there is a single operation: the delete is the committed position. offset mirrors poll's forward cursor, so commit(offset = polledPage.offset) deletes exactly the prefix just polled.

Stacked on #438 — base is feat/immutable-edge-scan-delete; review/merge that first. commit is the queue-level use of #438's scan-and-delete primitive. (The immutable-edge constraint from #440 is already in main.)

Single consumer per partition: committing deletes the prefix, so it assumes one logical consumer advancing a partition (Kafka-style), not independent consumers sharing one.

Changes

  • QueueService.commit(namespace, queue, partition, offset) — loops MutationService.scanDelete in pages of COMMIT_BATCH until the seq <= offset range is drained, returning the total deleted; validates the partition is in range.
  • MessageController: DELETE .../partitions/{partition}/messages?offset=X → QueueCommitResponse{namespace, queue, partition, committed}.
  • ReadOnlyRequestFilter classifies the endpoint as a write (blocked in read-only mode).

How to Test

  • ./gradlew :server:test --tests "*queue.v1.*" — includes a lifecycle E2E: enqueue seq 1..5, poll a batch of 3, commit(offset = page.offset), assert 3 deleted and a re-poll from the start returns only 4/5, then commit the rest and the partition drains.
  • ./gradlew :engine:spotlessCheck :server:spotlessCheck.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: claude code (opus 4.8)

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jul 21, 2026
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch 2 times, most recently from ae2cb22 to 78bfc14 Compare July 21, 2026 13:02
@em3s
em3s force-pushed the feat/queue-eviction branch 2 times, most recently from 207bd89 to cf7684f Compare July 21, 2026 13:39
@em3s em3s changed the title Add partition trim (retention/eviction) to queue/v1 Add commit (poll -> process -> commit) to queue/v1 Jul 21, 2026
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 78bfc14 to 28c795c Compare July 21, 2026 13:44
@em3s
em3s force-pushed the feat/queue-eviction branch from cf7684f to d08e0e1 Compare July 21, 2026 13:45
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 28c795c to fc9987b Compare July 21, 2026 13:49
@em3s
em3s force-pushed the feat/queue-eviction branch from d08e0e1 to 5af5def Compare July 21, 2026 13:50
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from fc9987b to 945a7ec Compare July 21, 2026 13:58
@em3s
em3s force-pushed the feat/queue-eviction branch from 5af5def to b3aeb1c Compare July 21, 2026 13:59
@em3s em3s mentioned this pull request Jul 21, 2026
1 task done
@em3s
em3s force-pushed the feat/immutable-edge-scan-delete branch from 945a7ec to 704c41b Compare July 21, 2026 14:48
@em3s
em3s force-pushed the feat/queue-eviction branch from b3aeb1c to f663df0 Compare July 21, 2026 14:48
Base automatically changed from feat/immutable-edge-scan-delete to main July 21, 2026 14:57
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 21, 2026
…offset

Add `DELETE /queue/v1/namespaces/{ns}/queues/{queue}/partitions/{partition}/messages?offset=X`.
A consumer polls a partition, processes the batch, then commits up to the batch's offset:
every message with `seq <= offset` is deleted. This is the poll -> process -> commit
lifecycle and doubles as retention/eviction (one op, since an immutable edge keeps no
per-message ack state — the delete is the state).

`QueueService.commit` loops the engine scan-and-delete (`MutationService.scanDelete`) in
pages of `COMMIT_BATCH` until the `seq <= offset` range is drained, returning the count
deleted. `offset` mirrors poll's forward cursor, so `commit(offset = polledPage.offset)`
deletes exactly the polled prefix.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/queue-eviction branch from f663df0 to 6f5999f Compare July 21, 2026 14:58
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 21, 2026
@em3s

em3s commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Optimistic

@em3s
em3s merged commit c25a620 into main Jul 21, 2026
2 checks passed
@em3s
em3s deleted the feat/queue-eviction branch July 21, 2026 15:37
@em3s em3s self-assigned this Jul 21, 2026
@em3s em3s mentioned this pull request Jul 21, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant