fixes: Runner stream state inconsistencies - #1910
Open
joschahenningsen wants to merge 3 commits into
Open
Conversation
Include the stream version in end-of-stream notifications so the backend can track which version ended and only mark the stream not-live once all versions have finished.
- Protect r.jobs and r.discard with a mutex to prevent concurrent map read/write crashes. - Split notification retries: critical notifications (StreamEnd, StreamStart, VODReady) retry indefinitely with capped backoff until delivered or the runner shuts down. Non-critical notifications keep bounded retries. - Cache the gRPC connection to the manager with keepalive parameters instead of creating a new connection per notification.
- Add 5 new DAO methods for per-version job tracking, stale stream detection, and orphaned job cleanup on runner re-registration. - Fix EndStream to always set LiveNow=false regardless of whether individual runner jobs could be cancelled. - Fix streamEnded to only mark a stream not-live after all versions have ended, not on the first StreamEndNotification. - Guard TriggerDueStreams against launching duplicate jobs for the same stream+version. - Add ReapStaleStreams to clean up streams stuck in live state when runners crash or notifications are permanently lost. - Clean orphaned runner jobs when a runner re-registers. - Register reapStaleStreams as a per-minute cron job.
kordianbruck
approved these changes
Aug 8, 2026
kordianbruck
left a comment
Member
There was a problem hiding this comment.
Overall looks good. I'm worried that this is risky in the sense of stopping properly working streams, but you added a decent amount of logging. The entire setup with job count is a rough abstraction for "is this stuff working properly", but it might get us there. IDK how much of this change I actually understand, but I would've hoped there was an easy path to not use mutex'es (but I assume that's fundamentally how one runner can process multiple streams).
No integration tests of course means you've properly smoke tested this yourself, right? 😉
| // fetch live stream previews | ||
| _ = tools.Cron.AddFunc("fetchLivePreviews", api.FetchLivePreviews(daoWrapper), "*/1 * * * *") | ||
| // reap streams stuck in live state due to runner crash or lost notifications | ||
| _ = tools.Cron.AddFunc("reapStaleStreams", m.ReapStaleStreams, "*/1 * * * *") |
Member
There was a problem hiding this comment.
Can we reduce the frequency here? should suffice to run this every 30 minutes only during the day, right?
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.
See individual commits for details.