Skip to content

Make fair task gc conditional on rangeid (#12283) - #12411

Merged
carlydf merged 1 commit into
release/v1.32.xfrom
fair-task-reader-bugfix-v1.32
Oct 7, 2026
Merged

carlydf merged 1 commit into
release/v1.32.xfrom
fair-task-reader-bugfix-v1.32

Conversation

@carlydf

@carlydf carlydf commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Add ConditionRangeID to CompleteTasksLessThanRequest and make CompleteTasksLessThan conditional on unchanged rangeid, just like CreateTasks.

When fair task reader gc's tasks, it's not protected by write fencing like adding tasks. So there's a small race window: a node advances its ack level to C, but it's not persisted yet. Another node takes over and loads the previous ack level, A. It writes a task above A but below C, call it B. The first node now deletes below C, deleting B. Note that this only happens with fair queues because fifo queues always write above the rangeid.

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)
  • validated in tla+ model (not in repo yet)

Note

High Risk
Changes fair-queue task deletion and ownership fencing; a bug could cause task loss or failed GC under partition handoff, though behavior mirrors existing CreateTasks range checks.

Overview
Fair task queue GC (CompleteTasksLessThan) can now be conditional on task-queue range_id, closing a race where a stale owner deletes tasks written by a new owner after range steal.

Persistence: CompleteTasksLessThanRequest gains optional ConditionRangeID (fair/v2 only). Classic v1 Cassandra/SQL reject it. Fair v2 Cassandra batches the delete with a range-id CAS; SQL runs delete inside a transaction after lockTaskQueue. Mismatch returns ConditionFailedError. A persistence suite test covers match vs wrong range id.

Matching: CompleteFairTasksLessThan passes the in-memory rangeID, holds db.lock to serialize with other LWTs, and does not log store errors on ownership loss. Fair reader GC calls signalIfFatal so ConditionFailedError unloads the queue.

Tests: Range-stealing engine tests are re-enabled with poll deadlines and relaxed post-GC task counts for the new matcher; backlog assertions use tasks above ack level.

Reviewed by Cursor Bugbot for commit c24b188. Bugbot is set up for automated code reviews on this repo. Configure here.

Add ConditionRangeID to CompleteTasksLessThanRequest and make
CompleteTasksLessThan conditional on unchanged rangeid, just like
CreateTasks.

When fair task reader gc's tasks, it's not protected by write fencing
like adding tasks. So there's a small race window: a node advances its
ack level to C, but it's not persisted yet. Another node takes over and
loads the previous ack level, A. It writes a task above A but below C,
call it B. The first node now deletes below C, deleting B. Note that
this only happens with fair queues because fifo queues always write
above the rangeid.

- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
- [x] validated in tla+ model (not in repo yet)
@carlydf
carlydf requested review from a team as code owners October 5, 2026 21:07
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @carlydf's task in 59s —— View job


Reviewed 9 files, 0 findings.

@carlydf
carlydf merged commit af08a5e into release/v1.32.x Oct 7, 2026
122 of 127 checks passed
@carlydf
carlydf deleted the fair-task-reader-bugfix-v1.32 branch October 7, 2026 18:18
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.

3 participants