Skip to content

fix(events): reserve watch clients atomically#249

Open
pkurunner wants to merge 1 commit into
ccfos:mainfrom
pkurunner:codex/fix-events-watch-client-limit-20260619
Open

fix(events): reserve watch clients atomically#249
pkurunner wants to merge 1 commit into
ccfos:mainfrom
pkurunner:codex/fix-events-watch-client-limit-20260619

Conversation

@pkurunner

Copy link
Copy Markdown
Contributor

Two /v1/events/watch requests can both pass the active-client check before either increments the counter, so max_clients is not a hard cap under concurrency.

This reserves the slot with CAS and releases the same counter on exit. I added a small concurrent test around that path.

Testing:

  • gofmt -w cmd/huatuo-bamai/handlers/events.go cmd/huatuo-bamai/handlers/events_test.go
  • Not run: go test ./cmd/huatuo-bamai/handlers on Windows is blocked by Linux-only github.com/prometheus/procfs/sysfs build constraints.
  • Not run: GOOS=linux GOARCH=amd64 go test -c ./cmd/huatuo-bamai/handlers is blocked locally by missing generated internal/toolstream/transport capnp types on main.

Signed-off-by: yeyangyi <2501210756@stu.pku.edu.cn>
@pkurunner

Copy link
Copy Markdown
Contributor Author

CI note: Build/Lint, PR name lint, and Ubuntu 22.04 VM passed. Ubuntu 20.04 failed in integration/test_dropwatch_ratelimit.sh with events=0 and rate-limit warnings=0; that path is unrelated to the /v1/events/watch client counter change here.

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