Skip to content

fix: preserve FIFO order in overflow buffer - #103

Merged
Yiming1997 merged 1 commit into
Yiming1997:mainfrom
1m55555555:fix/overflow-buffer-fifo
Sep 11, 2026
Merged

Yiming1997 merged 1 commit into
Yiming1997:mainfrom
1m55555555:fix/overflow-buffer-fifo

Conversation

@1m55555555

Copy link
Copy Markdown
Contributor

Summary

  • Preserve FIFO ordering when the overflow buffer cannot immediately hand a task to a worker.
  • Remove the oldest buffered task only after the handoff succeeds.
  • Add a regression test covering failed forwarding with an existing backlog.

Problem

When the handoff channel was full, PushAndForward removed the oldest task before attempting to forward it. If forwarding failed, it appended that task back to the tail of the buffer.

This allowed newer tasks to overtake older ones, violating FIFO semantics and potentially delaying old tasks indefinitely during sustained backpressure.

Solution

Peek at the oldest task first, attempt the handoff, and remove it from the buffer only when the handoff succeeds. If it fails, the task remains at the head unchanged.

Validation

  • go test ./...
  • go test -race -count=1 . -timeout 5m
  • go vet ./...

Scope

No public API changes. No changes to worker scaling, capacity limits, or task execution behavior.

@Yiming1997
Yiming1997 merged commit 7547f35 into Yiming1997:main Sep 11, 2026
1 check passed
@1m55555555
1m55555555 deleted the fix/overflow-buffer-fifo branch September 11, 2026 08:57
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