Skip to content

next_notification: never wait less than 1 ms - #2

Merged
casibbald merged 1 commit into
masterfrom
fix/next-notification-min-wait
Oct 27, 2026
Merged

casibbald merged 1 commit into
masterfrom
fix/next-notification-min-wait

Conversation

@casibbald

Copy link
Copy Markdown

next_notification could hang forever in a coroutine when the time left before its deadline dropped under 1 ms: may (up to 0.3.51) stores park timeouts in whole milliseconds and truncates shorter ones to 0, which it reads as "no timeout". The wait is now rounded up to 1 ms.

Found while switching LifeReflector to next_notification: its leader waits until the next deadline, so sub-millisecond remainders were routine. The may side is fixed separately (microscaler/may d74595b, merged to the fork's master in #3), but this keeps may_postgres safe on crates.io may.

  • src/client.rs: the guard.
  • tests/test/main.rs: next_notification_returns_for_sub_millisecond_timeouts (1 µs … 1.5 ms in a coroutine, bounded by a 10 s guard). It hangs without the fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y3TSRmEZAYU6RBUXhkn7WF

may keeps park timeouts in whole milliseconds and, up to 0.3.51,
truncates anything shorter to 0, which it reads as "no timeout". When
the time left before next_notification's deadline fell under 1 ms (a
caller waiting until a deadline, or a loop after a stale permit), the
wait in a coroutine never returned. Round the wait up to 1 ms.

Regression test: sub-millisecond timeouts in a coroutine return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y3TSRmEZAYU6RBUXhkn7WF
@casibbald
casibbald merged commit 15b4ab8 into master Oct 27, 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