Repository navigation
tiering: an unobtainable release is replaced by the next best copy; e2e for it and the other uses - #154
Merged
Conversation
…file Adds to tests/e2e/plex_e2e.py, in the existing style (counts and states on the PASS/FAIL/SKIP/INFO lines, ids only on DETAIL lines, changes put back in finally): T server transcode (lower bitrate, then another container), pulled as an HLS client S seek past the head, back before the fetch point, back into the head, forward again Z long pause past the slot, watched and read-wait timeouts, then resume M two streams at once (same file; a second file only when a role is named) P Plex's own analysis and folder scan must not fetch the whole file R arr refresh and rescan: same file record, the link is still ours, nothing fetched K audio and subtitle track switches during a play, selection put back W no demote starts while a watched file is fetched (read-only) audit nothing left dangling: link, stub and manifest of every row that is not whole rearm_try_row.py makes the try-row re-arm a reusable step (dry unless REARM_APPLY=1). llm_shadow_check.py checks, read-only, that the LLM layer is in shadow mode. The README says what each scenario costs, what should happen per use, and why arr rename, delete and upgrade stay a written plan. Scenarios run only on the real server through runner jobs; nothing here runs in CI.
… that changes state rearm_try_row.py no longer retires the consumed try row when no candidate passes, and refuses before writing when the allowlist would grow. The audit does not judge a row whose state changes while it is looked at (a fetch that ends mid-check). The harness header now lists E2E_WINDOW_S.
…ich scenario starts cold
…mote A played row stays whole for the idle window, so a try row that a scenario played while it still waited for its first demote would never be offloaded, and the re-arm kept it forever. It now reads Plex first and retires such a row like a consumed one. REARM_VERDICT_ONLY=1 stops after the verdict line, so a job can ask what would happen to the old try row without a search.
With E2E_ATTACH_S set, W waits that long for a session of the try row before it begins a play itself, so a job can start it beside S and have it sample the runner during S's fetch.
…-live by hand uses it When a release behind an offloaded file cannot be fetched, the next copy must take its place without the viewer noticing, and the row must be a normal row afterwards. - The pick: a candidate whose name says another edition or other language words is dropped, the nearest resolution is tried first (the same, higher, lower), and the pick (the planned alternative too) is imported and its first bytes are probed beside our own head: the run times must agree and the first sound track must be in the same language. What cannot be proved is dropped. substitute_pick and substitute_failed say why each candidate was dropped. - The integrity record: the hash build that reads the whole middle once also makes the whole file's SHA-256, so a substituted row has the same records as any row and promote keeps its one strict path. Before this the row had no sha256 and promote refused it for good. The runner waits with a promote while the manifest is pending, and never hashes a row that is retired or failed. - By hand: --switch-live goes through Runner._switch, the automatic switch's own path: the substitute instead of a full local restore, the same auto_switch event and the same owner alerts. Exit 1 when nobody could be switched. - A search that could not be done or checked no longer costs the six-hour cooldown. - The hash build opens its own database connection on its thread. tests/test_substitute_real_path.py runs the real modules end to end over a local remote: mark failed, switch by hand, hash build, promote, and the refusals.
… the try row now - D, G, E, F, H make the release unobtainable the way the owner does (--mark-failed), play the row on the real player and run --switch-live by hand. They check that the play goes on and how long it took, that Plex keeps the item, that the arr keeps its file and grabs nothing, that the pick is the same cut, that the new row is a normal row, that only the owner is told, and that nothing changes when no candidate qualifies. N waits for the runner's hash build and promote of the new row. No event is injected any more. - The try row is followed through a substitute to its newest row (harness, re-arm). - offload_try_row.py runs the runner's own single demote for the try row while the runner is paused, so a used row is cold again without waiting for a night.
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.
Goal
When the release behind an offloaded file cannot be fetched back (NZB gone, articles missing, a failed restore), the next best copy takes its place and the viewer does not notice. This PR holds the product change for that, the CI tests of its code path, and the real-stack scenarios that prove it, together with the earlier scenarios for the other ways Plex and the arrs use an offloaded file.
The seven checks, before and after
sha256: promote refused the row for goodProduct change (
tiering/offload)substitute.py,qualify.py, newprobe.py,newznab.py): a candidate whose name says another edition or other language words is dropped; the nearest resolution is tried first (the same, then higher, then lower); the pick, the planned alternative too, is imported and its first bytes are probed beside our own head. The run times must agree withinmax(SUBSTITUTE_RUNTIME_TOL_S, run time * SUBSTITUTE_RUNTIME_TOL_FRAC)(20 s, 0.5 %) and the first sound track must have the same language. What cannot be proved is dropped.substitute_pickandsubstitute_failedcarry the reason per dropped candidate.substitute.py,runner.py): the hash build already reads the whole file once for the chunk list; it now also makes the whole file's SHA-256, so a substituted row has the same records as any other row andops.promotekeeps its one strict path. A substitute has no earlier copy to compare with, so the strongest statement available is "the promoted file is exactly what the release served when it was hashed, with no holes"; a second, weaker verify path in promote would have been a second trust rule. The runner waits with a promote while the manifest is pending, and never hashes a row that is retired or failed.runner.py,switch_live.py):--switch-live <id>goes throughRunner._switch, the same function the automatic switch uses: the substitute instead of a full local restore, the sameauto_switchevent, the same owner alerts. Exit 1 when nobody could be switched. This changes what--switch-livedoes by hand;--checkis unchanged.OFFLOAD_DESIGN.mdandtiering/README.mddescribe the rules and the honest limits.Tests
tests/test_substitute_real_path.py, 8 tests): the real modules end to end with nothing stubbed between the steps:--mark-failed,--switch-liveby hand, the hash build the runner resumes, then a realops.promoteof the substituted row; plus the refusals (bytes that were not hashed, a changed head, no candidate, a dry run, a build that must run once across processes). Real sqlite, stub, manifest, chunk list and library link in a temp dir; the bytes are made at run time. Only the two far ends are stand-ins, because CI has no Usenet and no Plex.tests/e2e/plex_e2e.py, never run by CI; run by signed jobs on the server, on the one test row, with the real player):D: the release is unobtainable and nothing has replaced it: a play past the head waits.G: nothing qualifies: the real search runs, every candidate is dropped, the owner is told, the row stays as it was.E,H,F: the release is made unobtainable with--mark-failed, the row is played,--switch-liveruns: checks 1 to 6 (E the planned alternative, H with the player paused, F a live search with the runner running).N: the runner hashes the new row and then promotes it like any row, during a play.offload_try_row.py: the runner's own single demote for the test row while the runner is paused, so a used row is cold again without waiting for a night.Ttranscode,Sseeks,Zlong pause,Mtwo streams,PPlex's own tasks,Rarr refresh,Ktracks,Wdemote window,Lshadow decisions,audit, andrearm_try_row.py.Known limits (not fixed here)
bad_chunk. A release whose remote cannot be read at all stalls as a read error and is not switched by itself.Deploy
Through
update.sh. No setting changes its default.