Skip to content

docs(udp): describe stale idle-expiry handling as deadline revalidation - #1842

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
docs/udp-stale-timer-deadline-revalidation
Oct 3, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
docs/udp-stale-timer-deadline-revalidation

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Fixes #1825

Cause

CAUSE: lib/src/protocol/udp/LIFECYCLE.md ("Idle is a single armed deadline + generation tokens"), the flow.rs/manager.rs/mod.rs comments and the test names idle_race_resolved_by_generation_token / prop_generation_token_defeats_stale_close credit a per-flow generation token -> production only writes UdpFlow::timer_gen (UdpFlow::touch); UdpManager::handle_timeout selects and re-checks flows by idle_deadline <= now and never compares a captured generation -> SYMPTOM: the docs and tests name a mechanism that does not run. The invariant is actually upheld by deadline revalidation plus consume-then-reschedule. Separately, LIFECYCLE.md said UdpListenerSession::close drops the delivered timer_handle; the clear is in the timeout handler, UdpListenerSession::timeout_at (lib/src/udp.rs).

Decision: document, do not remove timer_gen

The issue offers two routes: describe the real mechanism, or wire a captured generation through the timer contract. Wiring one in would add a second mechanism to something that is already correct. Removing the write-only token is the other way to make the docs true, but timer_gen is a pub field of UdpFlow in the public sozu_lib::protocol::udp::flow module, and touch / on_client_datagram / on_backend_datagram return it. Dropping it would break the library API and still need the same doc rewrite. So this PR keeps the field and describes it as a refresh counter that touch advances and no expiry path reads. Removing it can be a follow-up if that API break is wanted.

Change (no behaviour change)

  • flow.rs: module doc, timer_gen field doc, touch doc, comment and debug_assert_ne! message, plus the on_*_datagram return docs.
  • manager.rs: module doc, the handle_timeout doc (deadline revalidation, timer_gen not consulted), and the strict-advance guard comment.
  • mod.rs: module doc.
  • LIFECYCLE.md: idle section rewritten around deadline revalidation, the test citation renamed, and UdpListenerSession::close replaced by UdpListenerSession::timeout_at.
  • doc/testing.md: the touch guard is described as a refresh counter, with a pointer to the property test that exercises revalidation.
  • Tests: idle_race_resolved_by_generation_token is renamed idle_race_resolved_by_deadline_revalidation and now also asserts the refreshed idle_deadline == t5 + 10s, the value handle_timeout actually checks. Its timer_gen assertion stays, with a reworded message. prop_generation_token_defeats_stale_close is renamed prop_deadline_revalidation_defeats_stale_close. No assertion was removed.
  • CHANGELOG entry under Unreleased / Changed.

git grep -n "generation token\|prop_generation_token\|resolved_by_generation" -- . ':!CHANGELOG.md' -> no hits.

Validation (on 0e22590)

  • cargo +nightly fmt --check -> exit 0
  • cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings -> exit 0
  • RUSTDOCFLAGS="-D warnings" cargo +1.93.1 doc --no-deps --locked -p sozu-lib -p sozu-command-lib -p sozu -> exit 0
  • cargo +1.93.1 test -p sozu-lib --lib --all-features --locked -> test result: ok. 1592 passed; 0 failed (including idle_race_resolved_by_deadline_revalidation ... ok, prop_deadline_revalidation_defeats_stale_close ... ok)
  • cargo +1.93.1 test -p sozu-e2e --locked --features opentelemetry,splice,simd udp_tests -> test result: ok. 16 passed; 0 failed
  • python3 .github/scripts/check_doc_citations.py --root . --base origin/main -> exit 0 (41 citations resolve, 71 cited lines unchanged, 1065 cited test names exist)

The UDP lifecycle docs, the flow/manager/mod comments and two test
names credited a generation token with keeping a stale wheel expiry
from closing a refreshed flow. `UdpManager::handle_timeout` never reads
`UdpFlow::timer_gen`: it closes a flow only while `idle_deadline <= now`,
and consume-then-reschedule re-arms the wheel.

Name that mechanism, describe `timer_gen` as a refresh counter no expiry
path reads (the public field stays), rename the two tests, and assert
the refreshed `idle_deadline` in the race test. Correct the LIFECYCLE
citation: the delivered `timer_handle` is dropped in
`UdpListenerSession::timeout_at`, not `close`. No behaviour change.

Fixes #1825

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit 4c51ba8 into main Oct 3, 2026
28 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.

Describe UDP stale timer handling as deadline revalidation

1 participant