Skip to content

fix(ring): serialize capacity and shutdown checks - #176

Open
bensynapse wants to merge 1 commit into
golang-queue:masterfrom
bensynapse:fix-ring-capacity-lock
Open

bensynapse wants to merge 1 commit into
golang-queue:masterfrom
bensynapse:fix-ring-capacity-lock

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

WithQueueSize(2) can admit four jobs when producers submit at the same time. Ring.Queue checks capacity before locking the buffer.
Ring.Request also reads count without locking during shutdown. Concurrent readers can trigger a data race and return ErrNoTaskInQueue after closure.

Move both checks inside the existing mutex so they share the lock with buffer updates. Add concurrent capacity and shutdown drain tests.

make test passes with race detection on Go 1.26.8 and 1.27.0. The focused regressions pass 50 runs with -race.
make lint, go build ./... and go vet ./... pass. Both example modules build and execute successfully.

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.

1 participant