fix(gateway): stop hygiene retry livelock after commit-fence cancel (salvage #96967) - #99514
Merged
Merged
Conversation
…96953) A /stop or /restart abort left hygiene with no cooldown, so the next turn re-armed auto-compression and waited up to 600s behind a fence that would refuse the commit again. Record a cooldown on fence-cancel and unwind, stop extending that wait once the fence is cancelled, and skip a new hygiene agent while a compression lock is already held.
Contributor
૮ >ﻌ< ა ci reviewran on 806e13d — test(gateway): cover hygiene fence-cancel cooldown and in-fl
|
This was referenced Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Salvage of #96967 (author: @HexLab98) rebased and composed onto current
main, fixing the hygiene-compression retry livelock reported in #96953: after/stopor/restartcancels the compression commit fence, session hygiene treated the cancelled attempt as a clean no-op, recorded no cooldown, and immediately re-armed auto-compression on the next inbound turn — each doomed round waiting toward the 600 s ceiling while inbound messages were demotedinterrupt→queue. Real-world impact: gateway unresponsive ~31 minutes with zero compression work committed (#96953, Feishu; independently reproduced on Telegram in the issue thread).What changed
hygiene_wait_should_extend()refuses to extend the wait once the fence is cancelled — a cancelled attempt can never ride the 600 s ceiling.try_cancel_before_commit()(which itself setsis_cancelled) so a genuine idle timeout is not mislabeled, and a fence-cancelled attempt persists a hygiene failure cooldown with a distinct reason string (cancelled at commit fence) — the next turn honors the cooldown instead of retrying immediately./restarttearing down the handler) also persists the cooldown across the process boundary (witnessed with a freshGatewayRunner/SessionDBpair).Composition notes (conflicts vs. current main)
The original PR predates three main-side changes in the same region; all are preserved:
_hyg_max_turn_hold_seconds) and its slice arithmetic — the 0.25 s cancel poll is applied as an extramin()cap, not a replacement._hyg_total_exhausted/ total-ceiling classification andretain_compression_lock_until_worker_done()([Bug]: Lean compaction ceiling timeout leaves detached workers and can falsely auto-reset sessions #97488) — fence-cancel reason takes precedence in the cooldown message only when the fence was actually cancelled._hygiene_compression_timeout_message()user-facing copy — unchanged for non-cancel timeouts.Verification (live before/after)
On
main@26f178e5fa, the PR's four behavioral witnesses fail (livelock gap present):With this branch:
tests/gateway/test_session_hygiene.py+test_hygiene_failure_cooldown_ladder.py+test_compression_in_flight_check.py— 60/60 passed; fulltests/gateway/suite green (the only 2 failures during development were pre-existing buzz-topology fakes, fixed independently on main bye7f6e22c3b; green after rebase).Fixes #96953
Closes #96967 (salvaged with authorship preserved — both commits are @HexLab98's, cherry-picked/rebased)
Infographic