You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Next Up rail wiped out after bulk mark-watched (row-capped anchor scan evicts all other series) #592
Reported by user vanbaster (web UI): marking one series watched from Continue Watching made the entire Next Up row disappear, and it stayed gone across logout/login.
Root cause
buildListNextUpQuery bounds the global anchor scan with nextUpAnchorMaxRows = 500 — a cap on raw completed rows, introduced in #350 to fix a real 44.7s regression. But the query only needs one anchor per series. A bulk mark-watched writes hundreds of completed rows with the newest timestamps; those rows flood the 500-row window and evict every other series.
Production evidence (2026-08-10 ~18:00 UTC, profile valfam of user 134):
Marking SpongeBob SquarePants watched wrote 572 completed rows in <2s (17:59:59.965 → 18:00:01.718).
The 500-row anchor window afterwards contained exactly 1 distinct series (the fully-watched one, which yields no next episode) → rail returned 0 rows.
Replaying the query unbounded returned the user's real 16-row rail — no data was lost, only unreachable.
The cap also degrades rails organically: on another prod profile (11k completed rows), the row-capped query returns 2 Next Up rows where a series-bounded scan returns the full 24.
Fix direction
Replace the row-capped anchor CTE with a recursive skip-scan (loose index scan) over idx_uwp_profile_completed that emits the newest row of each not-yet-seen series and stops after 96distinct series. One series can then never evict others. Compound (updated_at, media_item_id) cursor so same-timestamp bulk writes across different series aren't skipped. Series-scoped branch (show-detail tile) unchanged.
Measured on prod (PG 18.4), full generated query: worst profile (23k rows/271 series) ~210ms vs ~84ms old (acceptable; the correctness bug is disqualifying); typical heavy profile 102ms new vs 181ms old, returning 24 rows vs 2.
Activity
fix(catalog): anchor Next Up on the highest episode, not the highest ID
fix(catalog): bound Next Up anchors by distinct series, not rows (Sil…