Skip to content

test(concurrent): check the MaxConcurrent bound across the whole slot wait - #144

Merged
ThomasK33 merged 1 commit into
mainfrom
test/concurrent-bounded-check
Oct 30, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
test/concurrent-bounded-check

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Why

The operator wants every open follow-up fixed and landed, one small reviewed PR each. TestConcurrentBoundedByMaxConcurrent checked the handler log once, 80 ms after the second event, then freed the slot. A slot wait that lets the second handler run after that one check passed every run. This PR makes the test check the bound for the waiter's whole wait.

Follow-up from #141.

What changed

  • The test runs in a testing/synctest bubble. After it posts the second event, it sleeps on the fake clock until 1 ns before the waiter's DetachTimeout deadline, then checks that only the first handler ran. The fake clock moves only while every goroutine in the bubble is durably blocked. So the check covers the full slot wait, and the test takes no wall-clock time.
  • synctest.Wait replaces the 2 s polling loops that checked "first handler started" and "second runs after the slot frees".

Scope

Blast radius

The change touches one test. If the bound check fails, a sync.OnceFunc release frees the blocked handler, so the bubble reports the failure. Two limits remain. If the runtime never frees the slot, the test prints its failure and then synctest panics because blocked goroutines remain, which stops the package's test binary. If a goroutine blocks on a sync.Mutex, synctest.Wait waits until the go test timeout, so that failure can take up to 10 minutes to report.

Verification

  • I committed two wrong runtimes on local throwaway branches and never pushed them. A: the slot channel holds MaxConcurrent+1. B: the slot wait gives up after 100 ms and runs the handler anyway. The old test caught A (960 of 960 loaded runs) and missed B (0 of 200 normal runs, 0 of 960 loaded runs). With B, every other TestConcurrent* test also passes.
  • The new test fails A and B in 400 of 400 normal runs (-cpu=1,4) and fails B in 960 of 960 loaded runs (16 CPU spinners, 24 batches of 40 at -test.cpu=1). On this head it passes 400 of 400 normal runs and 960 of 960 loaded runs.
  • vet, root, adapter, and example tests, gofmt -l, and go test -race . all pass on the head.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

… wait

TestConcurrentBoundedByMaxConcurrent sampled the handler log once, 80 ms
after the second event, then freed the slot. A slot wait that let the
second handler run after that sample passed every time.

The test now runs in a testing/synctest bubble. It holds the only slot on
the fake clock until just before the waiter's DetachTimeout deadline. The
clock moves only while every goroutine is durably blocked, so the check
covers the waiter's whole wait.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T09:42:38.919912Z b22af89 Manual request
🔒 Security Review ✅ Completed 2026-10-30T09:42:47.700550Z b22af89 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: b22af895c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: b22af895c1

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 merged commit 0c4f13f into main Oct 30, 2026
2 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.

1 participant