Skip to content

test: the rate limit test allows for the tokens that refill while it runs - #41

Merged
giraffesyo merged 1 commit into
canaryfrom
test/deflake-rate-limit
Oct 2, 2026
Merged

giraffesyo merged 1 commit into
canaryfrom
test/deflake-rate-limit

Conversation

@giraffesyo

Copy link
Copy Markdown
Member

Summary

TestConformance/RateLimit failed the canary CI run of the 0.3.1 release commit on Postgres 17 (claim with an empty bucket = 1 jobs, wait 0s; want 0 and ~200ms). It is a timing assumption in the test; no library code changes.

The queue is limited to 5 jobs per second with a burst of 2. The test claims the burst and expects the next claim to get nothing. A token refills in 200 ms, and on a loaded runner more than that passed between the two claims, so the second claim correctly got one job.

The test now bounds what each claim may return by the time elapsed since the first one, instead of assuming the claims are closer together than a refill. On a fast machine the checks are as strict as before.

The closing check ("no more than rate × time + burst are ever claimed") could not fail: it allowed 12 jobs and only 10 were inserted. It now inserts 20 and compares against the measured time.

Testing

  • go test -race -count=8 -run TestConformance/RateLimit ./driver/... passes for both drivers against Postgres 17.
  • With a 300 ms sleep added between the first two claims, which reproduces the CI condition, the fixed test passes.
  • golangci-lint: 0 issues.

Only a test changed, so no hopperbench results.

Checklist

  • make check passes — lint and the changed test run locally; the full suite runs in CI here
  • No cryptography was added (tests run with GODEBUG=fips140=only)
  • New or changed SQL in the claim, finalize, rescue or leader paths has a concurrency or chaos test — no SQL changed
  • Behavior changes are reflected in docs/PLAN.md — none

@giraffesyo
giraffesyo merged commit d3fb5d3 into canary Oct 2, 2026
8 checks passed
@giraffesyo
giraffesyo deleted the test/deflake-rate-limit branch October 2, 2026 01:10
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