Files
buzz/crates
Wes 44e97e96f4 fix(pubsub): round the rate-limit retry hint up from PTTL (#9552)
## Summary

The Redis rate limiter built its `retry in Ns` hint from `TTL`, which
truncates to whole seconds. With 400 ms left in the window, a denied
request was told `retry in 0s`, and a client that sleeps for exactly the
hint retried straight into another refusal.

This reads `PTTL` and rounds the milliseconds up to whole seconds, so
the hint is never 0 while the window is still open. The no-expiry repair
path is unchanged.

## Testing

- New `rate_limiter::tests::retry_hint_rounds_a_partial_second_up`
(`#[ignore = "requires Redis"]`, like the other Redis tests in this
crate) seeds an exhausted window with 400 ms left and asserts the denial
reports 1 second. Against the old `TTL` code it fails with `left: 0,
right: 1`; with this change it passes.
- `cargo nextest run -p buzz-pubsub --lib`: 38 passed. Ignored Redis
`rate_limiter` and `nip98_replay` tests: 5 passed against a local Redis.
- `cargo nextest run -p buzz-relay --lib` with local Postgres and Redis:
1762 passed. The relay `rejection::`/`admission::` lane with
`--run-ignored all`: 16 passed.
- Pre-push hooks (including rust-tests) passed.

CI note: the Redis-backed pubsub tests only run in CI when they are
named in `.github/workflows/_ci-relay.yml`, so the new test isn't
selected there yet. Adding `or test(/^rate_limiter::tests::/)` to the
"Pubsub subscriber reconciliation regression" filter would cover it. I
left that out here because this branch can't push workflow file changes.

---------

Signed-off-by: Wes <wesb@block.xyz>
Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
2026-11-18 16:28:20 -05:00
..