Skip to content

fix(transcodenode): wait for a rebuild's own manifest before taking it as ready - #4251

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
rangoDJ:fix/node-rebuild-waits-for-its-manifest-4099
Nov 15, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
rangoDJ:fix/node-rebuild-waits-for-its-manifest-4099

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #4099
Related issue: #4097 (changed the lines next to these; merged)
Validation tasks: none

Other clients: N/A. The change is in the transcode node's rebuild; a client of a rebuilt session gets a working stream instead of one that serves nothing.

A rebuild on a transcode node reuses the lost session's output directory, which still holds the previous process's stream.m3u8 and segments. Under a backend that has a software retry (VideoToolbox, or QSV/VAAPI on a node with no render device), the rebuild waited with WaitForManifest. That accepts any manifest in the directory, and skips the startup-files check once FFmpeg has exited (s.running is false). A hardware process that died at startup was therefore ready from the old manifest: the node registered a session that served nothing, and the software retry that should have run was skipped.

This PR has no dependencies and can merge in any order. #4097, which the issue said to follow, is merged.

Approach

  • Both waits in spawnReconstruct (internal/transcodenode/server.go), the hardware start's and the software retry's, use WaitForGenerationManifest, which accepts only a manifest the current FFmpeg generation wrote. That is the wait the issue names.
  • A dead hardware start now reads as failed, so the software retry runs; a retry that fails too returns its error and nothing is registered, as TestSpawnReconstructDoesNotRegisterFailedSoftwareRetry already expects for an empty directory.
  • The automatic pipeline and the explicit-backend path, which don't take this branch, are unchanged.

Validation

  • gofmt, go vet and the changed-lines lint are clean.
  • New TestSpawnReconstructIgnoresThePreviousProcessManifest: the existing failed-retry setup (a fake FFmpeg whose real attempts all exit) plus an old stream.m3u8 and six segments in the session's output directory. It checks that the rebuild returns an error, registers nothing, and made two attempts, hardware and the software retry.
  • Negative: with main's WaitForManifest, the rebuild takes the dead process as ready and goes on to register it, reaching s.tracker.NodeURL() (server.go:2378), which panics because the test server has no tracker. The test therefore fails on main; it never gets back a session to check.
  • go test ./internal/transcodenode/ passes.
  • Not run: a real VideoToolbox or QSV node; the full make test-go.

Evidence

No visible change. The evidence is what the rebuild does with an old manifest in its directory, from the test on WSL2 (Ubuntu, go1.26.4 linux/amd64), main at 7fc39fbd0, this PR at the head of this branch.

Hardware rebuild dies at startup, old manifest present main This PR
Readiness ready from the old manifest failed
Software retry skipped runs
Retry fails too n/a error, nothing registered
$ go test -count=1 -run TestSpawnReconstructIgnoresThePreviousProcessManifest ./internal/transcodenode/   # main's WaitForManifest
panic: runtime error: invalid memory address or nil pointer dereference
	/home/kodi/silo-native/internal/transcodenode/server.go:2378   (registering the dead session)
FAIL

$ go test -count=1 -v -run 'TestSpawnReconstructIgnoresThePreviousProcessManifest|TestSpawnReconstructDoesNotRegisterFailedSoftwareRetry' ./internal/transcodenode/
--- PASS: TestSpawnReconstructDoesNotRegisterFailedSoftwareRetry (0.03s)
--- PASS: TestSpawnReconstructIgnoresThePreviousProcessManifest (0.03s)
ok  	github.com/Silo-Server/silo-server/internal/transcodenode	0.140s

Risks

  • A rebuild whose hardware process is alive but slow behaves as before: the wait times out, the session is kept, and no retry starts.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code (Claude desktop app, Code tab)
  • Tool(s): Claude Code; GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Fix transcodenode.Server.spawnReconstruct readiness to require current-process manifest

The reconstructed session and the software-encoding retry both reuse the output directory, so a manifest left by a previous process could falsely mark the session ready. Both readiness checks in server.go now wait for a manifest written by the current process.

  • Adds a regression test, TestSpawnReconstructIgnoresThePreviousProcessManifest, that seeds an existing HLS manifest and segments, fails both ffmpeg attempts, and confirms an error is returned, the session is not registered, and both hardware and software encoding are tried.

Macroscope summarized bf30719.

…t as ready

A rebuild on a transcode node reuses the lost session's output
directory. Under a backend with a software retry (VideoToolbox, or
QSV/VAAPI on a node with no render device) it waited with
WaitForManifest, which accepts any manifest in the directory, and skips
the startup-files check once FFmpeg has exited. A process that died at
startup was then ready from the previous process's manifest: the
rebuild registered a session that served nothing, and the software
retry never ran.

Both waits now use WaitForGenerationManifest, which accepts only a
manifest the current process wrote. The dead start reads as failed, so
the software retry runs, and a retry that also fails is not registered.

Closes Silo-Server#4099

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bea84920-cb4a-4648-919d-e7ce9da2a00a
Commits

Reviewing files that changed from the base of the PR and between 931517f and bf30719.

Files selected for processing: 2

  • internal/transcodenode/server.go
  • internal/transcodenode/server_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish labels Nov 15, 2026
@Quick104

Copy link
Copy Markdown
Contributor

🤖 Claude Code (claude-opus-5-5)

Review summary

Reviewed head: bf307197fd1ee1cab335130d7553bc21bd06e579

No findings. Both readiness waits in spawnReconstruct now accept only a manifest the current FFmpeg process wrote. The automatic rebuild path (StartReconstructTranscode) and handleStart's startup retry already wait this way, so the explicit-backend rebuild now follows the same rule. FFmpeg replaces stream.m3u8 with a temp file and a rename on every write, so the inherited-manifest check also covers the case where the dead hardware attempt left a playlist: the software retry records that playlist as inherited when it spawns.

Verification

  • TestSpawnReconstructIgnoresThePreviousProcessManifest fails on the base: the rebuild registers the dead session and reaches the tracker. It passes on this head in repeated runs.
  • go test ./internal/transcodenode/ passes and make lint-changed reports no issues.
  • I didn't test on a real VideoToolbox or QSV node.
  • A Codex (gpt-6.1-sol) cross-provider review of this head found nothing this PR introduced. It checked the retry's own inherited-manifest capture, the planned-copy and restart paths, which this change leaves alone, and the slow-but-running first attempt, which is still kept.

Follow-up. The same review found a separate problem that's already on main: the software retry is closed even when FFmpeg is still running at the readiness deadline, unlike every other rebuild attempt. The fix changes the lines this PR changes, so it's filed as #4263 to follow this PR.

Validated features. I couldn't read the 1.0 validation board for this run. From the code, the change only reaches rebuilds on a transcode node whose backend has a software retry (VideoToolbox, or QSV/VAAPI without a render device), so Validation tasks: none looks right.

User manual. Unaffected: no setting, label, or documented behavior changes.

Other clients. N/A: the change is internal to the transcode node.

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

  • Fit: this fixes a reliability bug in recovering from a lost transcode, using the readiness wait the other startup paths already use, without adding a setting or a new code path.
  • Readiness: a two-line change at the right place, with a regression test that fails on the base. The one gap is that it wasn't run on real hardware.

@Quick104
Quick104 merged commit 61a9253 into Silo-Server:main Nov 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] A transcode node registers a dead rebuild as ready when its output directory still holds an earlier manifest

2 participants