fix(lite): keep follow sessions alive across dormancy#301
Merged
Conversation
Keep streamer dormancy from tearing down unbounded live-read followers while a follow subscription is active. Wrap follow receivers with a drop guard so the streamer wakes up when the last follower disconnects, and add a regression test for the dormant follower path.
Contributor
Greptile SummaryThis PR fixes a bug where a lite streamer would exit due to the dormancy timeout while active follow subscribers were still connected. It introduces a Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Client (read.rs)
participant SC as StreamerClient
participant S as Streamer (run loop)
participant FG as FollowGuard
C->>SC: follow(start_seq_num)
SC->>S: Message::Follow
S->>FG: FollowGuard::new() [active_followers += 1]
S-->>SC: Ok(FollowReceiver { _guard, rx })
SC-->>C: Ok(FollowReceiver)
note over S: dormancy select branch<br/>disabled (active_followers != 0)
C->>C: follow_rx.recv() [streaming records ...]
C->>FG: drop(FollowReceiver)
FG->>FG: fetch_sub → active_followers = 0
FG->>S: Message::FollowerDropped (wake-up)
note over FG: guard dropped
S->>S: receive FollowerDropped (no-op handler)
S->>S: loop top: load active_followers == 0
S->>S: reset dormancy timer (dormant_timeout)
note over S: dormancy branch now enabled
S->>S: dormancy fires → break (streamer exits)
Last reviewed commit: 6bac2e8 |
Add a paused-time regression that exercises Backend::read through the full follow path and verifies an unbounded session survives streamer dormancy before receiving new data.
Remove the actor-level dormancy test and its helper scaffolding now that the paused-time Backend::read regression covers the real user-visible failure mode.
Drop the now-unused run_with_dormant_timeout helper after moving dormancy coverage to the integration-level follow test.
Move the unbounded follow dormancy regression into backend::read tests so it can advance past streamer::DORMANT_TIMEOUT directly instead of hardcoding 61 seconds, and drop the duplicated integration test.
Use explicit acquire/release semantics for the follow subscriber counter so the synchronization does not rely on the mpsc wake-up path being inferred.
Drop the separate follow subscriber counter and decide dormancy expiry directly from follow_tx.receiver_count() when the timeout fires.
Serialize follow subscription lifetime through the streamer actor so dormancy checks cannot race queued follow requests. Increment the follower count when processing Follow, decrement it on a FollowerDropped message sent from the receiver drop guard.
Bias the streamer select loop so pending write completions and inbound messages are handled before the dormancy timeout branch. This prevents queued follow requests from losing to dormancy once follower lifetime is tracked inside the actor.
Yield once after advancing past DORMANT_TIMEOUT in the paused-time read regression so the streamer can take the dormancy branch before the follow-up append arrives. This makes the test fail reliably without the fix.
Merged
shikhar
pushed a commit
that referenced
this pull request
Mar 6, 2026
## 🤖 New release * `s2-lite`: 0.29.19 -> 0.29.20 (✓ API compatible changes) * `s2-sdk`: 0.24.6 -> 0.24.7 (✓ API compatible changes) * `s2-cli`: 0.29.19 -> 0.29.20 <details><summary><i><b>Changelog</b></i></summary><p> ## `s2-lite` <blockquote> ## [0.29.20] - 2026-03-06 ### Features - Default append pipelining with durability-gated acks ([#289](#289)) ### Bug Fixes - Keep follow sessions alive across dormancy ([#301](#301)) ### Miscellaneous Tasks - Dep updates ([#299](#299)) <!-- generated by git-cliff --> </blockquote> ## `s2-sdk` <blockquote> ## [0.24.7] - 2026-03-06 ### Miscellaneous Tasks - Dep updates ([#299](#299)) <!-- generated by git-cliff --> </blockquote> ## `s2-cli` <blockquote> ## [0.29.20] - 2026-03-06 ### Bug Fixes - Handle Ctrl+C during bench catchup ([#297](#297)) <!-- generated by git-cliff --> </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: s2-release-plz[bot] <262023388+s2-release-plz[bot]@users.noreply.github.com>
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.
Summary
DORMANT_TIMEOUTand proves an unbounded follow session survives idle periodsTesting
Closes #300