Skip to content

fix(pool): synchronize waiting task count snapshots - #149

Merged
alitto merged 1 commit into
alitto:mainfrom
zhechen-cs:codex/waiting-task-count
Oct 17, 2026
Merged

alitto merged 1 commit into
alitto:mainfrom
zhechen-cs:codex/waiting-task-count

Conversation

@zhechen-cs

Copy link
Copy Markdown
Contributor

WaitingTasks() reads the linked buffer's write and read counters without the mutex used by queue producers and consumers. A consumer can advance between those reads, leaving the sampled read count ahead of the sampled write count. Len() interprets that as counter rollover and reports a value near math.MaxUint64 for a small queue.

Read the count under the existing pool mutex, as the other queue operations do. The regression concurrently samples a bounded queue while tasks are submitted and consumed, and checks that the reported count stays within its capacity.

Validation (Go 1.26.9, macOS):

  • On unmodified 7b7c16a, the race-enabled regression failed in 6 of 10 runs, reporting counts such as 18446744073709551614 for a 64-entry queue. The single run without -race passed.
  • With the fix, the regression passes all 10 runs with -race.
  • make test-ci passes (go test -race -v -timeout 1m -count=3 ./...).
  • go vet ./... and git diff --check pass.

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.77%. Comparing base (7b7c16a) to head (9108daf).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #149      +/-   ##
==========================================
+ Coverage   95.75%   95.77%   +0.01%     
==========================================
  Files          11       11              
  Lines         613      615       +2     
==========================================
+ Hits          587      589       +2     
  Misses         23       23              
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alitto alitto left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good one, thanks!

@alitto
alitto merged commit 9b1e439 into alitto:main Oct 17, 2026
49 of 50 checks passed
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