Skip to content

Fix stream monitor showing non-cumulative data transfer for HLS streams#47

Merged
sparkison merged 3 commits intom3ue:devfrom
Warbs816:fix/preserve-bytes-on-stream-recycle
Mar 23, 2026
Merged

Fix stream monitor showing non-cumulative data transfer for HLS streams#47
sparkison merged 3 commits intom3ue:devfrom
Warbs816:fix/preserve-bytes-on-stream-recycle

Conversation

@Warbs816
Copy link
Copy Markdown
Contributor

Summary

  • Preserve total_bytes_served, total_segments_served, and created_at when recycling orphaned streams in get_or_create_stream()
  • HLS variant streams always have 0 registered clients (clients register with the parent), so they were being recycled on every playlist refresh (~every few seconds), resetting their byte counters each time
  • The stream monitor aggregates variant stats into the parent stream for display, but the variant's counters kept getting wiped, causing data transferred to fluctuate instead of accumulate

Safety

The preserved fields are purely stats counters — never used in pooling, failover, cleanup, or routing logic. All operational state (failover, error counts, circuit-breaker, URLs) still resets as before.

…treams

Variant HLS streams always have 0 registered clients (clients register
with the parent stream), so they get recycled on every playlist refresh.
This reset total_bytes_served and total_segments_served to 0, causing
the stream monitor to show fluctuating data transfer values instead of
cumulative totals.
@Warbs816 Warbs816 marked this pull request as ready for review March 23, 2026 00:59
@sparkison
Copy link
Copy Markdown
Member

Thank you! I'll review and merge shortly...

Make sure restore block is guarded by recycle state rather than non-zero counters.

Added assert recycled_created_at is not None to narrow the type and satisfy the type checker, since the field is guaranteed non-None when was_recycled is True.

Add tests!
Copy link
Copy Markdown
Member

@sparkison sparkison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@sparkison sparkison merged commit afc69e7 into m3ue:dev Mar 23, 2026
4 checks passed
@Warbs816 Warbs816 deleted the fix/preserve-bytes-on-stream-recycle branch March 23, 2026 21:21
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.

2 participants