fix(seats): widen the lock budget in the concurrency tests (CI flake) #103

Merged
amiryahaya merged 2 commits from fix/seats-concurrency-test-flake into main 2026-10-26 17:22:45 +01:00
Owner

Fixes a CI flake seen on PR #102: TestHoldsAcrossTwoNodes (seats pgstore) failed with seats: busy, try again when the runner was overloaded (platform/postgres took 542 s, sales/pgstore 430 s). The commits queued on the day rows outlasted the fixed 3 s lock budget; the test's own comment already recorded the same failure once.

What

  • The seats store's lock budget (const lockWait, 3 s) is now a Store field: New sets the default (still 3 s), Store.WithLockWait(d) returns a copy with another budget, and bounded takes it as a parameter. All 7 call sites use the store's budget. Production behaviour is unchanged.
  • The three hammer tests and the two-node test in reserve_concurrency_test.go widen it to 15 s. A real deadlock is still reported as 40P01 -> ErrBusy by Postgres within about 1 s, so the tests still fail on one.
  • New test TestWithLockWait_ChangesTheBudget (written first; it did not compile before the option existed).

Review

Dual pass done: Pass 1 (ponytail) no Must fix (one comment corrected, 2884c27); Pass 2 approved with no Critical or Important findings.

Known limits

  • Not proven: the failure appeared only on the overloaded runner, so this makes it much less likely, not impossible.
  • Tests with the same default-3 s weakness, not changed here: placeAll in internal/sales/pgstore/checkout_test.go (the likeliest next flake), two concurrent tests in sales/pgstore/complete_test.go, and the wallet concurrency tests.
  • WithLockWait is exported only for tests.

Checks

make cover: 89.3% (minimum 80%). go test -race -count=3 ./internal/seats/..., make lint green locally. No migration, no deploy change.

🤖 Generated with Claude Code

Fixes a CI flake seen on PR #102: `TestHoldsAcrossTwoNodes` (seats pgstore) failed with `seats: busy, try again` when the runner was overloaded (`platform/postgres` took 542 s, `sales/pgstore` 430 s). The commits queued on the day rows outlasted the fixed 3 s lock budget; the test's own comment already recorded the same failure once. ## What - The seats store's lock budget (`const lockWait`, 3 s) is now a `Store` field: `New` sets the default (still 3 s), `Store.WithLockWait(d)` returns a copy with another budget, and `bounded` takes it as a parameter. All 7 call sites use the store's budget. Production behaviour is unchanged. - The three hammer tests and the two-node test in `reserve_concurrency_test.go` widen it to 15 s. A real deadlock is still reported as 40P01 -> ErrBusy by Postgres within about 1 s, so the tests still fail on one. - New test `TestWithLockWait_ChangesTheBudget` (written first; it did not compile before the option existed). ## Review Dual pass done: Pass 1 (ponytail) no Must fix (one comment corrected, `2884c27`); Pass 2 approved with no Critical or Important findings. ## Known limits - Not proven: the failure appeared only on the overloaded runner, so this makes it much less likely, not impossible. - Tests with the same default-3 s weakness, not changed here: `placeAll` in `internal/sales/pgstore/checkout_test.go` (the likeliest next flake), two concurrent tests in `sales/pgstore/complete_test.go`, and the wallet concurrency tests. - `WithLockWait` is exported only for tests. ## Checks `make cover`: **89.3%** (minimum 80%). `go test -race -count=3 ./internal/seats/...`, `make lint` green locally. No migration, no deploy change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
TestHoldsAcrossTwoNodes failed on a slow CI runner (#102): the commits queued
on the day rows outlasted the fixed 3 s budget and a hold got ErrBusy. The
budget is now a Store field (Store.WithLockWait, default still 3 s) and the
concurrency tests widen it to 15 s; production behaviour is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
docs(seats): say how fast a deadlock is reported in the concurrency tests
All checks were successful
ci / changes (pull_request) Successful in 14s
ci / clients (pull_request) Has been skipped
ci / api (pull_request) Successful in 10m51s
ci / ci-gate (pull_request) Successful in 4s
2884c2759c
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!103
No description provided.