Skip to content

fix(nodes): keep a move's job when another move starts the transport there - #4432

Closed
rangoDJ wants to merge 20 commits into
Silo-Server:mainfrom
rangoDJ:fix/4364-move-start-keeps-moved-job
Closed

rangoDJ wants to merge 20 commits into
Silo-Server:mainfrom
rangoDJ:fix/4364-move-start-keeps-moved-job

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: #4363 (which builds on #4337). Merge order: #4337, #4363, then this. #4337 has already merged. Until #4363 merges, this diff also shows #4363's commits and the feature-branch commits under it. This pull request's own commit is 45fbbdef5 (6 files, +91/−4).

Problem

Closes #4364
Related issue: #4363
Validation tasks: none

Other clients: N/A (no client-visible change)

When two API servers moved the same transcode to the same node at about the same time, that node could end up running nothing for it. The first move's start succeeded and it committed, so the stored recipe named the node. The second move's start then reached the node, and handleStart closed the first move's job and published its own under the same transport id. The second move's commit failed, because the session no longer named the dead node, so it released the start it sent. With #4363 that release names the second start, which is now the job on the node, so the node ended it. The viewer stalled until the next segment request rebuilt the job from the recipe. This affects deployments with several API servers and remote transcode nodes.

With this change the second move's start leaves the first move's job running.

Approach

A start that carries a start_id (only a move sends one) answers 409 instead of replacing a job that a start with a different start_id published. The check runs in handleStart under the transport's lifecycle lock, before anything is spawned. The losing move treats the 409 like any refused candidate: it rolls back with its own start_id, which #4363 already turns into a 404 that leaves the other job alone, and it tries the next node. Its commit would have failed anyway.

A start without start_id still replaces any job, so a fresh start, an audio switch and a Jellyfin-compatible start behave as before. So does a move onto a job that a rebuild published. A node that predates start_id ignores it and replaces as before. A core that predates it sends none.

I chose a refusing start over a release that names its job, because #4363 already fences the release. The remaining hole was the start replacing the winner's job.

docs/transcode-node-api.md, docs/architecture/worker-http-protocol.md, the start route's protocol description and the regenerated contracts/api/v2/openapi.json describe the 409.

Validation

  • Not reproduced on a deployment. The trigger needs two API servers moving one transport to the same node within the time a start takes.
  • One new test calls the real node handlers: two move starts, then the losing move's release, then a fresh start. It fails on fix(nodes): end only the job a late node release was sent for #4363's head (d466691c3) and passes with the fix.
  • go test for internal/transcodenode and internal/playback/...: pass.
  • go test ./internal/api/handlers/: six DB tests fail before and after this change, because the local test database is missing newer columns (client_session_id, timeline_duration_seconds). No handler code changed here.
  • make lint-changed against fix(nodes): end only the job a late node release was sent for #4363's head: 0 issues. make apiv2-openapi regenerated the contract, and make verify-apiv2-openapi reports it current.

Evidence

Nothing visible changes. The node test, before the fix (on #4363's head d466691c3):

=== RUN   TestHandleStop_ReleaseForAnotherStartLeavesNewerJob
--- PASS: TestHandleStop_ReleaseForAnotherStartLeavesNewerJob (0.00s)
=== RUN   TestHandleStart_MoveStartLeavesJobAnotherMovePublished
    release_fence_test.go:120: after both moves the node runs nothing for the transport
--- FAIL: TestHandleStart_MoveStartLeavesJobAnotherMovePublished (0.00s)
=== RUN   TestHandleStop_ReleaseLeavesJobPublishedWhileItWaited
--- PASS: TestHandleStop_ReleaseLeavesJobPublishedWhileItWaited (0.00s)
FAIL
FAIL	github.com/Silo-Server/silo-server/internal/transcodenode	0.082s

After the fix (45fbbdef5):

=== RUN   TestHandleStop_ReleaseForAnotherStartLeavesNewerJob
--- PASS: TestHandleStop_ReleaseForAnotherStartLeavesNewerJob (0.00s)
=== RUN   TestHandleStart_MoveStartLeavesJobAnotherMovePublished
--- PASS: TestHandleStart_MoveStartLeavesJobAnotherMovePublished (0.00s)
=== RUN   TestHandleStop_ReleaseLeavesJobPublishedWhileItWaited
--- PASS: TestHandleStop_ReleaseLeavesJobPublishedWhileItWaited (0.00s)
PASS
ok  	github.com/Silo-Server/silo-server/internal/transcodenode	0.091s

Package runs after the fix:

ok  	github.com/Silo-Server/silo-server/internal/transcodenode	8.130s
FAIL	github.com/Silo-Server/silo-server/internal/api/handlers	110.570s   (6 DB tests, same failures before the change)
ok  	github.com/Silo-Server/silo-server/internal/playback	170.567s
ok  	github.com/Silo-Server/silo-server/internal/playback/connectionstore	0.650s
ok  	github.com/Silo-Server/silo-server/internal/playback/contract	4.307s
ok  	github.com/Silo-Server/silo-server/internal/playback/dovirpu	0.190s
ok  	github.com/Silo-Server/silo-server/internal/playback/keyframes	9.183s
ok  	github.com/Silo-Server/silo-server/internal/playback/planstore	0.885s
lint-changed: 2 package(s) changed since d466691c30da5a3169d19e40f4d2d97453d0eae1
0 issues.
contracts/api/v2/openapi.json is current

Risks

  • A move onto a node that still runs an older move's job for the same transport is refused there, even when that job is stale. For example, the node was only briefly unreachable and the retire of it never landed. The move tries the next node. If that node was the only candidate, the move fails, and the old job keeps running until the next request or the idle reaper. Before this change the move would have replaced it.
  • Jellyfin-compatible moves send no start_id, so this rule does not cover them.
  • Only the node changes behavior. A mixed fleet is safe: an older node replaces as before, and an older core sends no start_id.

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 in the Claude desktop app
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Keep a move's job when another move starts the transport there, and add per-node keys and source grants

  • Replaces the shared JWT secret with per-transcode-node signing keys: a new nodeauth.Keyring, a credential registry with encrypted keys in stream_nodes.node_key_ciphertext (migration), admin key issuance (POST /admin/nodes/{id}/key), and signing throughout playback, proxy, downloads, trickplay, chapterthumbs, and subsync
  • Adds core-issued source grants: transcode-node start, remux, trickplay, chapter, download, and media-sample requests now carry a source_grant and open inputs through the core's sources/open route instead of an approved input path, with mount-mismatch 409s and renewal
  • Fixes the move race the PR title names: moves now use unique start IDs, check deny markers after destination start before committing, write the replacement-node recipe before retiring the old transport, and scope rollback to only their own start (playback_transcode_rehome.go, server.go)
  • Adds a new node control plane: node-to-core signed requests (VerifyFromNode), config/report/log/resolve/source/revoke endpoints, a standalone MODE=transcode runner driven by SILO_CORE_URL and SILO_NODE_KEY, and stops/releases that distinguish fenced stops from superseded releases
  • Behavioral Change: nodes without an issued key are excluded from planning, reservation, and acquisition (TranscodePool.HasKey); remote relays return 502/410 instead of falling back to the shared secret; recipe deletion on stop now keeps cards issued for another route (DeleteUnlessIssuedElsewhere); NODE_URL is no longer required in transcode mode

Macroscope summarized 45fbbde.

Quick104 and others added 20 commits November 14, 2026 19:16
Adds the per-node credential that thin transcode nodes will sign with.
Nothing signs with it yet, so existing nodes behave as before.

- stream_nodes.node_key_ciphertext holds the key encrypted under the row
  AAD. It is a credential, not configuration: issuing one moves neither
  the admin revision nor the pool generation.
- POST /api/v2/admin/nodes/{id}/key issues or rotates a key and returns it
  once. Node rows gain key_issued, and the node capabilities gain
  node_keys. Proxies take no key (409).
- nodepool.KeyRegistry holds every node's credential, disabled nodes
  included, on API servers and proxies. It reloads on node_pool_changed,
  every minute, and on a lookup miss at most once a second. A proxy that
  starts before the column is migrated keeps running and loads it later.
- Two transcode nodes can no longer be saved at one canonical URL, since
  the registry finds a node by that address.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The core now signs every request to a transcode node with that node's key,
and the node verifies with the same key from SILO_NODE_KEY. The shared
secret signs only requests to proxies.

- nodeauth splits signing by direction: core to node and node to core use
  separate HKDF labels and canonical versions, so a request captured in
  one direction never verifies in the other. The node-to-core signature
  also covers the source grant header.
- Senders name the kind of node they target. The registry's keyring gives
  a transcode target only that node's key and gives a proxy target the
  shared secret only for a URL registered as a proxy. An unknown URL and a
  keyless node are errors; neither falls back to the shared secret.
- A transcode node without a usable key stays listed and health-checked
  but takes no new work.
- The node's signed routes accept no legacy bearer.
- HTTP clients that call a node refuse redirects explicitly.

The node still holds its database and Redis; later commits remove them.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Adds the routes a thin transcode node will call instead of reading the
database and Redis itself. Nodes do not call them yet.

- nodecontrol.RequireNode verifies a node-signed request against the key
  registry and puts the node id in the request context. Handlers take the
  node's identity only from there. A disabled node is accepted; a deleted,
  keyless or proxy row gets 401.
- GET /api/internal/nodes/self/config returns the calling node's settings
  with its row overrides applied, with the revision as a strong ETag. A
  test fails when the node reads a config field the document lacks.
- POST .../self/report replaces the node's session records and telemetry
  snapshot, fenced on (boot_id, seq) so a replayed or older report changes
  nothing. Keys are scoped by the authenticated node id.
- POST .../self/logs stores a log batch under the authenticated node and
  clamps entry timestamps to the core's clock.
- POST .../self/health-changed publishes node_drain_changed.
- Report, logs and health-changed share a per-node request budget.
- The routes stay out of the request log, the activity log and response
  compression, and the worker protocol contract lists them as node_signed.

miniredis is added for tests: CI has no Redis, and the report fence and
session replacement are Lua scripts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Each transcode node shows whether it has a key, with a warning that a node
without one takes no work. On a server that can issue keys, an admin can
issue or rotate the key. Rotation asks for confirmation and says the
node's running streams fail until it restarts with the new key.

The new key is shown once, with the SILO_CORE_URL and SILO_NODE_KEY
settings the node starts with. It is kept in the dialog's state only, and
the dialog cannot be closed while the request is in flight. A refusal
shows the server's reason; a lost answer says the key may have rotated.

Creating a transcode node offers to issue its key.

The translation pin names a local catalog commit. Re-sync to a published
release before this merges.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The core now makes the decisions a transcode node made from Redis and the
shared secret. Nodes do not call the new routes yet.

- POST /api/internal/nodes/self/resolve answers the recipe and playback
  identity for a node rebuilding a lost HLS session or serving a
  progressive remux: deny checks, token verification, and a recipe bound
  to the calling node. A complete stored card wins over a complete token,
  because a move rewrites the card while the client keeps its old token.
  A recipe store read error is 503.
- POST /api/internal/nodes/self/revoke-recipes revokes the calling node's
  recipes, for the node to call inside its own force-reload teardown.
- A remote stop deletes the transport's stored recipe before it tells the
  node, unless the recipe names another node URL. A release deletes
  nothing. jellycompat reuses a transport id across start candidates, so a
  late stop on one must not remove the next one's recipe.
- Every dead-node move writes the stored recipe naming the new executor,
  for sessions whose URLs carry a token too. jellycompat recipes bind the
  node they started on.
- Every relay that signs a request to a transcode node checks the deny
  marker first, and a move rechecks it before it commits and before it
  serves.
- A node's 401 and a failure to sign for a node reach clients as the node
  being unavailable, not as a client auth failure. Neither moves the
  transcode: a replica with a stale key registry cannot sign for any node.
  /api/v2 delivery maps a relay 502 to dependency_unavailable.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The core now signs a source grant for every job it sends a transcode node:
a stateless capability to use one revision of one catalog file, or theme
file, through one node. Nodes do not use grants yet and still approve
paths against the catalog themselves.

- A grant names the node, the file or theme id, the fspath-encoded catalog
  path, the size and the modification time, and lasts an hour. Its key is
  derived from auth.jwt_secret under its own label. Revisions compare the
  modification time at microseconds, the catalog's precision.
- Native and Jellyfin-compatible starts, dead-node moves, download
  preparation, trickplay, chapter thumbnails and subtitle-sync samples
  carry source_grant. A move sends the replacement node a fresh grant.
  When no grant can be minted the work fails over or runs locally as a
  failed dispatch does.
- POST /api/internal/nodes/self/sources/open exchanges a grant for the
  approved path and a renewed grant. It refuses another node's grant
  (403), a source that left the catalog or the disk (410) and a changed
  size or modification time (412).
- Resolve checks that the catalog still has the recipe's file or theme and
  adds a grant for the calling node.
- nodesource.Opener is the node side: it opens a grant against the node's
  own mount, refuses a mount whose revision differs, and renews the grant
  while the source is open.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…crets

A transcode node now starts with two settings, SILO_CORE_URL and
SILO_NODE_KEY, and holds no database, Redis, data cipher, event bus or
shared secret. There is one transcode node type and no legacy mode: nodes
from before this change cannot work with an updated core, or the reverse.
Proxies are unchanged.

- MODE=transcode branches before the bootstrap. DATABASE_URL, REDIS_URL,
  SECRET_KEY, NODE_URL and NODE_NAME are ignored with one warning. A
  plain-HTTP core URL off the host logs a warning, because the node takes
  its FFmpeg path, directories and input paths from the core's answers.
- The node reads its configuration from the core, polls it every 30
  seconds, and rereads it when the core pushes a reload. The core pushes
  after a drain request or resume and after a change to a node's
  overrides. An unchanged poll keeps the configuration pointer.
- Sessions and stream telemetry stay in memory and go to the core in a
  report every second. Logs, FFmpeg output included, ship to the core.
  Drain changes are reported to the core instead of the event bus.
- The node verifies no stream token and reads no deny marker or recipe.
  A lost HLS session and every progressive remux request ask the core's
  resolve route, after the node's own stop fences. A force reload asks the
  core to revoke the node's recipes first.
- Every job opens its input with the source grant it carries, at the
  approved path on the node's own mount. A mount whose file differs from
  the core's answers 409. The catalog path authorizers are gone.
- Health carries the node control version and key_rejected. The core
  treats a transcode node without the version, or with a rejected key, as
  unhealthy, so a node on an older build is not placed.
- The omnibus init and the shipped Compose file no longer ask a transcode
  node for database or Redis settings.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- config now shares the per-node background budget, and resolve and
  sources/open get a budget of their own (200 a second, burst 600), so a
  node key cannot loop catalog reads without bound. A node treats 429 as
  transient on every route.
- Log entries a node ships are normalized before they are stored: an
  address that does not parse is cleared and node-supplied text is capped.
  A bad row no longer makes the core retry the batch row by row, and the
  dropped-entries warning is logged at most once a minute per node.
- Issuing a key publishes node_pool_changed even when the pool reload
  fails, and a node's 401 asks the credential registry to reload, so a
  replica holding a replaced key heals in seconds.
- A dead-node move writes the new node's stored recipe as soon as the move
  commits, then retires the old node. Nodes no longer delete recipes, so
  the wait left a window where the new node could not rebuild.
- A chapter thumbnail job a node cannot serve reports the reason the core
  falls back to local extraction for.
- A rejected key is described with both causes: a replaced key or a clock
  more than 30 seconds off.
- A progressive remux request checks the node's own state before it asks
  the core.
- make dev-transcode starts a node with SILO_CORE_URL and SILO_NODE_KEY.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
docs/architecture/transcode-nodes.md is the authority for the design: node
keys, signing in both directions, the node control routes, playback
authority on the core, source grants, failure behavior and security
properties. docs/update-to-1.0.md gains the operator steps for the
coordinated node upgrade. Other documents link to the new one and no
longer say that a transcode node reads the database, Redis or the shared
secret.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e rejects

- Creating, updating or deleting a node now reloads this server's
  credential registry before the response and publishes
  node_pool_changed, and reconciliation invalidates the registry when the
  node list changes. A deleted node kept signing and being signed for
  until the registry's 60-second reload.
- A transcode node shutting down on SIGTERM no longer waits for its
  sessions while the main server rejects its key: no relay can reach
  them and nothing will stop them. After a key rotation without a drain,
  the restart waited out the 10-minute drain timeout.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…te-transcode-nodes

- .silo-translations, web/src/locales/*, .silo-translations-files: took
  main's, then regenerated with sync-translations --local from the
  rebased silo-translations branch (pin local-de1af480da75).
- go.mod/go.sum: kept miniredis/gopher-lua beside main's bumped
  go-keyring and xxh3; go mod tidy.
- scripts/ci/db-contracts.txt: kept both sides' entries.
- contracts/api/v2/openapi.json: regenerated; the node protocol's
  playback_RecipeCard schema gains main's adaptation_reasons.
- internal/transcodenode: main's new spawnReconstruct test passes a
  nodecontrol.Resolution, as this branch's spawnReconstruct takes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- A source grant check that fails for a reason other than a missing file
  (an I/O error, a stale network mount) now answers 503, which the node
  retries. It answered 410, which ends the job, so a transient stat error
  on the API server stopped a transcode of an unchanged file. Minting a
  grant classifies the error the same way.
- A full log throttle searches for expired keys at most once per interval.
  A flood of unknown node ids paid for a pass over all 4,096 keys on every
  refused request.
- The resume primer test from main set no node keys, so its proxy route
  was never taken and it passed only where a local FFmpeg was installed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…te-transcode-nodes

# Conflicts:
#	.silo-translations
#	web/src/locales/keys.ts
A node's request budget admits twenty log batches a second, and one batch
may be 1 MiB, so a node key could write about 20 MiB a second into the
operational log. Log batches now also spend a per-node byte budget on each
API server: 128 KiB a second with bursts of 4 MiB. A node past it gets 429,
which it already retries.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A transcode node's release (a stop with fence=0) ended whatever job ran
under the transport id. A move's rollback and the retire of the node a
transport left both send it in the background, so it could land after
another API server's move started the same transport on that node and
end the newer job; the viewer stalled until the next segment request
rebuilt it.

A move's start now carries a start_id, and its rollback names it: the
node ends only that start's job. A retire names no start, so the node
ends only the job it held when the release arrived, not one a start or
rebuild published while the release waited for the lifecycle lock.
Fenced stops still end any job.

Closes Silo-Server#4359

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clarify the handleStop and test comments on what a release waiting for
the lifecycle lock leaves running, and describe the retire as a release
in the node API doc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…there

When two API servers moved one transport to the same node at once, the
second move's start replaced the job the first move had started and
committed. The second move's commit then failed, and it released its own
start, which ended the only job left: the node ran nothing for the
transport until the next segment request rebuilt it.

A start that carries a start_id now answers 409 instead of replacing a
job another start with a different start_id published. The losing move
moves on to the next candidate, and its rollback names its own start, so
the node leaves the winner's job running. A start without start_id (a
fresh start or an audio switch) still replaces any job, and a node or
core that predates start_id behaves as before.

Closes Silo-Server#4364

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

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 291 files, which is 141 over the limit of 150.

To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

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.

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: a7127d75-8f2b-41df-add6-6b0017e83437
Commits

Reviewing files that changed from the base of the PR and between c58c0bb and 45fbbde.

Files ignored due to path filters: 1

  • go.sum is excluded by !**/*.sum
Files selected for processing: 291

  • .env.example
  • DEVELOPMENT.md
  • Makefile
  • README.md
  • cmd/silo/main.go
  • cmd/silo/network_access_multinode_test.go
  • cmd/silo/node_drain.go
  • cmd/silo/node_drain_test.go
  • cmd/silo/node_keys.go
  • cmd/silo/node_keys_db_test.go
  • cmd/silo/transcode_node.go
  • cmd/silo/transcode_node_test.go
  • contracts/api/v2/openapi.json
  • contracts/api/v2/route-inventory.json
  • docker-compose.yml
  • docs/admin-api.md
  • docs/architecture/media-sampling.md
  • docs/architecture/node-drain.md
  • docs/architecture/node-failure-detection.md
  • docs/architecture/omnibus-image.md
  • docs/architecture/playback-protocol-v3.md
  • docs/architecture/restart-resilient-playback.md
  • docs/architecture/secret-encryption.md
  • docs/architecture/subtitle-sync.md
  • docs/architecture/transcode-nodes.md
  • docs/architecture/trickplay.md
  • docs/architecture/worker-http-protocol.md
  • docs/playback-api.md
  • docs/transcode-node-api.md
  • docs/update-to-1.0.md
  • go.mod
  • internal/activitylog/middleware.go
  • internal/activitylog/middleware_path_test.go
  • internal/api/handlers/admin_node_commands_test.go
  • internal/api/handlers/admin_node_configuration.go
  • internal/api/handlers/admin_node_configuration_test.go
  • internal/api/handlers/admin_node_drain.go
  • internal/api/handlers/admin_node_drain_test.go
  • internal/api/handlers/admin_node_key.go
  • internal/api/handlers/admin_node_network_access.go
  • internal/api/handlers/admin_node_network_access_test.go
  • internal/api/handlers/admin_node_reload.go
  • internal/api/handlers/admin_node_reload_test.go
  • internal/api/handlers/admin_playback_control_test.go
  • internal/api/handlers/device_sightings_test.go
  • internal/api/handlers/downloads_network_access_test.go
  • internal/api/handlers/downloads_test.go
  • internal/api/handlers/nodes.go
  • internal/api/handlers/nodes_reprobe_test.go
  • internal/api/handlers/nodes_test.go
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_connection_test.go
  • internal/api/handlers/playback_control_socket_v2_test.go
  • internal/api/handlers/playback_copy_safety_test.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_lazy_markers_test.go
  • internal/api/handlers/playback_lifecycle_db_test.go
  • internal/api/handlers/playback_lifecycle_test.go
  • internal/api/handlers/playback_probe_test.go
  • internal/api/handlers/playback_profile_refresh_test.go
  • internal/api/handlers/playback_proxy_test.go
  • internal/api/handlers/playback_relay_authority_test.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/playback_session_missing_test.go
  • internal/api/handlers/playback_session_recipe_test.go
  • internal/api/handlers/playback_test.go
  • internal/api/handlers/playback_transcode_rehome.go
  • internal/api/handlers/playback_transcode_rehome_test.go
  • internal/api/handlers/playback_transcode_serve_reconstruct_test.go
  • internal/api/handlers/playback_transport.go
  • internal/api/handlers/playback_transport_security_test.go
  • internal/api/handlers/playback_v3.go
  • internal/api/handlers/playback_v3_bitrate_policy_test.go
  • internal/api/handlers/playback_v3_capability_retry_test.go
  • internal/api/handlers/playback_v3_commit_order_test.go
  • internal/api/handlers/playback_v3_dead_node_test.go
  • internal/api/handlers/playback_v3_downloaded_subtitle_outage_test.go
  • internal/api/handlers/playback_v3_drain_test.go
  • internal/api/handlers/playback_v3_native_recovery_test.go
  • internal/api/handlers/playback_v3_network_access_test.go
  • internal/api/handlers/playback_v3_node_hwaccel_test.go
  • internal/api/handlers/playback_v3_node_recipe_test.go
  • internal/api/handlers/playback_v3_origins_test.go
  • internal/api/handlers/playback_v3_preflight_verdict_test.go
  • internal/api/handlers/playback_v3_route_nodes_test.go
  • internal/api/handlers/playback_v3_startup_cancel_test.go
  • internal/api/handlers/playback_v3_subtitle_facts_test.go
  • internal/api/handlers/playback_v3_subtitle_rendition_test.go
  • internal/api/handlers/playback_v3_subtitle_route_test.go
  • internal/api/handlers/playback_v3_subtitle_version_test.go
  • internal/api/handlers/playback_v3_test.go
  • internal/api/handlers/playback_v3_tokenless_test.go
  • internal/api/handlers/playback_v3_union_test.go
  • internal/api/handlers/session_ws_pause_state_test.go
  • internal/api/handlers/session_ws_plan_invalidated_test.go
  • internal/api/handlers/stream_copy_safety_test.go
  • internal/api/handlers/system.go
  • internal/api/handlers/system_test.go
  • internal/api/middleware/request_logger.go
  • internal/api/router.go
  • internal/api/subtitle_sync_wiring.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/admin_node_commands_test.go
  • internal/apiv2/admin_node_configuration.go
  • internal/apiv2/admin_node_drain.go
  • internal/apiv2/admin_node_key.go
  • internal/apiv2/admin_nodes_read.go
  • internal/apiv2/document.go
  • internal/apiv2/playback_delivery.go
  • internal/apiv2/playback_delivery_test.go
  • internal/apiv2/router.go
  • internal/apiv2/worker_protocols.go
  • internal/apiv2/worker_protocols_test.go
  • internal/apiv2/worker_streaming_test.go
  • internal/cache/redis.go
  • internal/chapterthumbs/remote.go
  • internal/chapterthumbs/remote_signing_test.go
  • internal/chapterthumbs/service.go
  • internal/chapterthumbs/service_test.go
  • internal/config/bootstrap.go
  • internal/config/bootstrap_test.go
  • internal/downloadprepare/transport.go
  • internal/downloadprepare/transport_test.go
  • internal/downloads/artifacts.go
  • internal/downloads/prepare_observer_test.go
  • internal/downloads/remote_preparer.go
  • internal/downloads/remote_preparer_security_test.go
  • internal/downloads/remote_preparer_test.go
  • internal/downloads/service.go
  • internal/downloads/service_remote_test.go
  • internal/downloads/storage_maintenance.go
  • internal/jellycompat/audio_selection_test.go
  • internal/jellycompat/auto_transcode_fallback_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/manifest_tonemap_failover_test.go
  • internal/jellycompat/network_access_test.go
  • internal/jellycompat/playback_contract_test.go
  • internal/jellycompat/playback_finish_test.go
  • internal/jellycompat/playback_report_liveness_test.go
  • internal/jellycompat/relay_authority_test.go
  • internal/jellycompat/remote_relay_transport_test.go
  • internal/jellycompat/remote_tonemap_capability_transport_test.go
  • internal/jellycompat/remote_transcode_reconstruct_test.go
  • internal/jellycompat/router.go
  • internal/jellycompat/routing_policy_test.go
  • internal/jellycompat/server.go
  • internal/jellycompat/streams.go
  • internal/jellycompat/streams_segment_error_test.go
  • internal/jellycompat/streams_test.go
  • internal/jellycompat/tone_map_inventory_test.go
  • internal/jellycompat/transcode_failover.go
  • internal/jellycompat/transcode_failover_test.go
  • internal/logstream/drain.go
  • internal/logthrottle/throttle.go
  • internal/logthrottle/throttle_test.go
  • internal/mediasample/remote.go
  • internal/mediasample/remote_signing_test.go
  • internal/mediasample/request.go
  • internal/nodeauth/nodeauth.go
  • internal/nodeauth/nodeauth_test.go
  • internal/nodeauth/nodeauthtest/nodeauthtest.go
  • internal/nodeauth/nodetocore.go
  • internal/nodeauth/nodetocore_test.go
  • internal/nodeconfig/remote.go
  • internal/nodeconfig/remote_test.go
  • internal/nodeconfig/watcher.go
  • internal/nodecontrol/auth.go
  • internal/nodecontrol/client.go
  • internal/nodecontrol/client_test.go
  • internal/nodecontrol/config_coverage_test.go
  • internal/nodecontrol/fixture_test.go
  • internal/nodecontrol/limit.go
  • internal/nodecontrol/protocol.go
  • internal/nodecontrol/protocol_registry.go
  • internal/nodecontrol/registry_db_test.go
  • internal/nodecontrol/reporter.go
  • internal/nodecontrol/reporter_test.go
  • internal/nodecontrol/resolve.go
  • internal/nodecontrol/resolve_test.go
  • internal/nodecontrol/revoke.go
  • internal/nodecontrol/server.go
  • internal/nodecontrol/server_test.go
  • internal/nodecontrol/sources.go
  • internal/nodecontrol/sources_test.go
  • internal/nodepool/admin_configuration.go
  • internal/nodepool/dial.go
  • internal/nodepool/drain.go
  • internal/nodepool/drain_test.go
  • internal/nodepool/gpuidentity_test.go
  • internal/nodepool/health.go
  • internal/nodepool/health_drift_proxy_test.go
  • internal/nodepool/health_stats_test.go
  • internal/nodepool/health_test.go
  • internal/nodepool/keyregistry.go
  • internal/nodepool/keyregistry_test.go
  • internal/nodepool/network_access_test.go
  • internal/nodepool/nodekey.go
  • internal/nodepool/nodekey_db_test.go
  • internal/nodepool/nodekey_test.go
  • internal/nodepool/nodepooltest/nodepooltest.go
  • internal/nodepool/planner.go
  • internal/nodepool/planner_test.go
  • internal/nodepool/repository.go
  • internal/nodepool/transcode_pool.go
  • internal/nodepool/unreachable_test.go
  • internal/noderecipe/store.go
  • internal/noderouting/resolver_test.go
  • internal/nodesessions/ingest.go
  • internal/nodesessions/local.go
  • internal/nodesource/grant.go
  • internal/nodesource/grant_test.go
  • internal/nodesource/nodesourcetest/nodesourcetest.go
  • internal/nodesource/protocol.go
  • internal/nodesource/source.go
  • internal/nodesource/source_test.go
  • internal/opslog/consumer.go
  • internal/opslog/consumer_db_test.go
  • internal/opslog/consumer_test.go
  • internal/playback/recipecard.go
  • internal/playback/remote_delete_signing_test.go
  • internal/playback/remote_stop_after_failure_test.go
  • internal/playback/remote_stop_recipe_test.go
  • internal/playback/transcode_manager.go
  • internal/proxy/download_test.go
  • internal/proxy/mediagrant_test.go
  • internal/proxy/node_refusal_test.go
  • internal/proxy/router_socket_test.go
  • internal/proxy/segment_completion_test.go
  • internal/proxy/server.go
  • internal/proxy/streamdeny_test.go
  • internal/routeinventory/classify.go
  • internal/scanner/file_repo.go
  • internal/scanner/file_repo_active_file_db_test.go
  • internal/streamtelemetry/node_report.go
  • internal/streamtelemetry/node_report_test.go
  • internal/subtitles/subsync/sampler.go
  • internal/subtitles/subsync/service.go
  • internal/subtitles/subsync/service_test.go
  • internal/transcodenode/auto_transcode_fallback_test.go
  • internal/transcodenode/capability_client.go
  • internal/transcodenode/capability_snapshot_test.go
  • internal/transcodenode/chapter_protocol.go
  • internal/transcodenode/download_prepare_protocol.go
  • internal/transcodenode/drain_test.go
  • internal/transcodenode/encoder_reporting_test.go
  • internal/transcodenode/media_routes_test.go
  • internal/transcodenode/media_sample.go
  • internal/transcodenode/media_sample_test.go
  • internal/transcodenode/node_auth_test.go
  • internal/transcodenode/nodefakes_test.go
  • internal/transcodenode/path_authorizer.go
  • internal/transcodenode/path_authorizer_test.go
  • internal/transcodenode/protocol_registry.go
  • internal/transcodenode/release_fence_test.go
  • internal/transcodenode/reprobe_test.go
  • internal/transcodenode/required_audio_test.go
  • internal/transcodenode/resolve.go
  • internal/transcodenode/route_inventory_test.go
  • internal/transcodenode/runtime.go
  • internal/transcodenode/server.go
  • internal/transcodenode/server_test.go
  • internal/transcodenode/source_input.go
  • internal/transcodenode/start_protocol.go
  • internal/transcodenode/start_protocol_test.go
  • internal/transcodenode/stop_protocol.go
  • internal/transcodenode/streamdeny_test.go
  • internal/transcodenode/streaming_protocol.go
  • internal/transcodenode/streamtelemetry.go
  • internal/transcodenode/streamtelemetry_test.go
  • internal/transcodenode/theme_audio_test.go
  • internal/transcodenode/thin_node_test.go
  • internal/transcodenode/trickplay.go
  • internal/transcodenode/trickplay_test.go
  • internal/transcodeproxy/completion.go
  • internal/transcodeproxy/completion_test.go
  • internal/transcodeproxy/refusal.go
  • internal/trickplay/remote.go
  • internal/trickplay/remote_capacity_test.go
  • internal/trickplay/remote_fallback_test.go
  • internal/trickplay/remote_test.go
  • migrations/sql/20261114234057_add_stream_node_key.sql
  • omnibus/rootfs/etc/s6-overlay/scripts/init-config
  • omnibus/rootfs/etc/silo-omnibus/migrate-compose-stack
  • scripts/ci/db-contracts.txt
  • web/src/api/types.ts
  • web/src/api/v2/operations.ts
  • web/src/api/v2/schema.ts
  • web/src/hooks/queries/admin/nodes.ts
  • web/src/hooks/queries/keys.ts
  • web/src/pages/AdminNodes.test.tsx
  • web/src/pages/AdminNodes.tsx

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 17, 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 17, 2026
Comment on lines +47 to +50
if err := h.nodeKeyRegistry.Refresh(refreshCtx); err != nil {
slog.WarnContext(ctx, "node credential reload after an admin change failed; this server applies the change on its next reload",
"component", "api", "node_id", nodeID, "error", err)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Security critical

Failed credential reload leaves revoked node keys authorized

If KeyRegistry.Refresh fails after the commit, revoked keys remain usable until a later successful reload. Evict the affected credential locally or otherwise fail closed before returning.

Prompt for LLM
File internal/api/handlers/admin_node_key.go, lines 47-50:

Failed credential reload leaves revoked node keys authorized

If the post-commit registry refresh fails, the operation still succeeds while `KeyRegistry.Refresh` retains the old key, so a deleted node or holder of a rotated key can continue authenticating until a later successful reload. Immediately evict the affected credential from the local registry on refresh failure, or otherwise fail closed before returning.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The credential reload concern comes from #4337 and is outside the scope of PR #4432’s own commit. It makes sense to leave the comment unresolved for maintainers to assess separately.

Comment on lines +481 to +484
// A local transport never reads the stored node card, and one left naming
// the node the transport left would let that node rebuild it. A session
// moved before carries a card even when its URLs carry a token.
h.deleteNodeRecipeV3(ctx, remoteTransportID(session))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug critical

Local move can delete a concurrent successor's node recipe

A concurrent move can publish a remote successor before deleteNodeRecipeV3 deletes its recipe, preventing reconstruction after a node restart. Serialize deletion with route changes and verify that the current route is still local.

Prompt for LLM
File internal/api/handlers/playback_transcode_rehome.go, lines 481-484:

Local move can delete a concurrent successor's node recipe

The unconditional recipe deletion runs after the local route commits without checking whether another move has since published a remote successor for the same transport ID. A concurrent successor can therefore lose its newly written recipe and fail to reconstruct after a node restart; serialize the deletion with route changes and verify that the current route is still local.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The flagged line is from #4337, not this PR’s own commit, so I’ll leave the suggestion unresolved for maintainers to decide. The potential race can be assessed separately from the move-start fix in #4432.

stopCtx, cancel := context.WithTimeout(detached, compatTranscodeMoveTimeout)
defer cancel()
if err := h.tm.ReleaseRemoteTranscode(stopCtx, upstreamSessionID, deadNodeURL); err != nil {
if err := h.tm.ReleaseRemoteTranscode(stopCtx, upstreamSessionID, deadNodeURL, ""); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

A delayed release can stop a successor transcode on the old node

If a transport moves from node A to B and back to A, a delayed ReleaseRemoteTranscode call can stop the successor job because its start identifier is empty. Fence the release with a generation that identifies rebuilt jobs or another conditional release mechanism.

Also found in:

  • internal/api/handlers/playback_transcode_rehome.go:843-843

Kody rule violation: Fence transcode cleanup against adoption and successor startup

Prompt for LLM
File internal/jellycompat/transcode_failover.go, line 426:

A delayed release can stop a successor transcode on the old node

Fence this asynchronous release to the runtime generation being retired. If the transport moves from node A to B and then back to A before this request arrives, the empty start identifier allows the delayed release to stop the successor job on A. Carry a generation that also identifies rebuilt jobs, or use another conditional release mechanism that cannot remove a successor.

**Also found in:**
- `internal/api/handlers/playback_transcode_rehome.go:843-843`

Kody rule violation: [Fence transcode cleanup against adoption and successor startup](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/bc550d90-a21e-4a7e-9d8f-c00d68eb74e8?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This release comes from #4363 (d67b11e), and this PR's own change is 45fbbde. #4363's Risks section names this case: a release without start_id can still end a newer job that is already running on that node. This PR doesn't change it, because it only stops a move's start from replacing another move's job.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed. The unfenced retirement release comes from #4363 and is a documented risk there, not a regression introduced by #4432’s own commit. This PR addresses a separate race: preventing one move’s start from replacing another move’s job.

The delayed-release scenario remains a valid concern, but it should be tracked separately rather than treated as a blocker specific to this PR.

if strings.TrimSpace(secret) == "" {
return nil, refuseUnavailable
}
claims, err := streamtoken.Verify(token, secret)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules critical

Node resolution accepts capabilities without checking the login session

streamtoken.Verify does not establish that the originating login session is still active, so a revoked session can continue resolving HLS and remux media. Validate the session on every resolution request and require account authentication for legacy unbound tokens.

Kody rule violation: Bind playback capabilities to revocable login sessions

Prompt for LLM
File internal/nodecontrol/resolve.go, line 128:

Node resolution accepts capabilities without checking the login session

Cryptographic verification alone does not establish that the login session which authorized this playback capability is still active. Both HLS and remux resolution use this result to reconstruct media, so a revoked login session can continue using an otherwise valid token. Validate the capability's originating login session on every resolution request, and require account authentication for legacy unbound tokens rather than treating them as standalone authority.

Kody rule violation: [Bind playback capabilities to revocable login sessions](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/5e22b6f6-b2e0-41a4-ac6f-c632ec350748?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed. The suggestion concerns code from the already-merged #4337, not PR #4432’s move-start change in 45fbbdef5. Leaving it unresolved for maintainers is reasonable.

The security concern may still warrant a separate follow-up; its being out of scope for this PR does not establish whether it is valid.

Comment on lines +355 to +357
if !themesongs.Unchanged(claims.MediaPath, claims.ThemeSize, time.Unix(0, claims.ThemeModifiedUnixNano)) {
return nil, refuseSourceChanged
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Transient theme stat failures permanently reject remux requests

A transient theme file stat failure makes themesongs.Unchanged trigger refuseSourceChanged, returning 400 instead of allowing a retry. Distinguish missing or changed files from other filesystem errors and return 503 for transient failures.

Prompt for LLM
File internal/nodecontrol/resolve.go, lines 355-357:

Transient theme stat failures permanently reject remux requests

A transient stat failure on a theme file is classified as a permanent source change, so the node returns 400 instead of retrying the playback request. Distinguish missing or changed files from other filesystem errors and return 503 for transient failures.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The finding is out of scope for PR #4432 because the line comes from the already-merged #4337. It remains unresolved for the maintainers to decide whether to pursue separately.

http.Error(w, http.StatusText(status), status)
return
}
if _, err := claims.Check(r.Context()); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules critical

Source opens check the receiving replica's filesystem

claims.Check checks the receiving replica's filesystem, which may contain a different file or produce a terminal response when the grant owner is unavailable. Route the open request to the admitting owner incarnation, preserving the grant and returning a retryable failure if that owner is unavailable or restarted.

Also found in:

  • internal/nodecontrol/sources_test.go:231-231
  • internal/nodesource/grant.go:148-148
  • internal/nodesource/source.go:363-363
  • internal/nodesource/grant.go:80-80
  • internal/nodecontrol/sources.go:81-81

Kody rule violation: Keep Go worker sources bound to their owner and file revision

Prompt for LLM
File internal/nodecontrol/sources.go, line 69:

Source opens check the receiving replica's filesystem

Route the open request to the grant's admitting owner incarnation before checking the source. This handler currently checks the path on whichever API server receives the request, so another replica can interpret the same path as a different file or return a terminal response for an unavailable owner. Preserve the grant and return a retryable failure if that owner is unavailable or has restarted.

**Also found in:**
- `internal/nodecontrol/sources_test.go:231-231`
- `internal/nodesource/grant.go:148-148`
- `internal/nodesource/source.go:363-363`
- `internal/nodesource/grant.go:80-80`
- `internal/nodecontrol/sources.go:81-81`

Kody rule violation: [Keep Go worker sources bound to their owner and file revision](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/8623ef2e-b7a2-4301-91b3-59e4cd4ba3c5?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The source-open finding appears to come from #4337 rather than this PR’s own commit, so I’ll leave the suggestion unresolved for the maintainers to decide on. It may be worth tracking separately if they confirm it remains an issue.

Comment on lines +134 to +135
if grant, err = s.regrant(ctx, node.ID, file, grant); err != nil {
return nil, nodeLabel(node), err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

A transient regrant failure bypasses local subtitle sampling fallback

A transient s.regrant failure after the first window fails subtitle synchronization in prefer_transcode_nodes mode, unlike an initial grant failure. Fall back locally for the remaining windows while still rejecting an actual source revision change.

Prompt for LLM
File internal/subtitles/subsync/sampler.go, lines 134-135:

A transient regrant failure bypasses local subtitle sampling fallback

A transient source-grant failure after the first window immediately fails subtitle synchronization even in `prefer_transcode_nodes` mode, despite that mode falling back locally when the initial grant fails. Fall back for the remaining windows on transient regrant failures while still rejecting an actual source revision change.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed. The suggestion concerns code from #4337, not this PR’s move-start change, so it’s reasonable to leave it unresolved for maintainers to decide whether to address separately.

removeCtx, cancelRemove := context.WithTimeout(context.WithoutCancel(r.Context()), sessionTrackingOperationTimeout)
s.tracker.Remove(removeCtx, trackerSessionID)
cancelRemove()
s.tracker.Remove(r.Context(), trackerSessionID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Stopped session cleanup depends on the request context

A canceled request can prevent s.tracker.Remove from releasing the session record after the job has stopped. Use a context detached from request cancellation with an explicit timeout.

Also found in:

  • internal/transcodenode/server.go:1119-1119

Kody rule violation: Detach mandatory cleanup from request cancellation and bound its lifetime

Prompt for LLM
File internal/transcodenode/server.go, line 2707:

Stopped session cleanup depends on the request context

Run tracker removal with a context detached from request cancellation and bounded by an explicit timeout. The job has already been stopped, so a canceled request must not prevent its session record from being released.

**Also found in:**
- `internal/transcodenode/server.go:1119-1119`

Kody rule violation: [Detach mandatory cleanup from request cancellation and bound its lifetime](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/b3c20cf3-6a41-4161-9af6-2bef16b674e9?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The cleanup finding is outside PR #4432’s own change and appears in the stacked diff. I’ll leave it unresolved for the maintainers to assess; no changes have been made.

slog.Warn("remove transcode session directory", "component", "transcodenode", "session", sessionID, "error", err)
}
if s.tracker != nil {
s.tracker.Remove(context.Background(), sessionID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Detached session cleanup can block indefinitely

s.tracker.Remove can block indefinitely while holding the session lifecycle lock if the backing store is unavailable. Bound the detached context with a fixed timeout and cancel it afterward.

Kody rule violation: Cancel blocking lifecycle work before waiting and bound detached cleanup

Prompt for LLM
File internal/transcodenode/source_input.go, line 150:

Detached session cleanup can block indefinitely

Bound the detached tracker removal with a fixed timeout and cancel the context afterward. An unbounded removal can block indefinitely when the backing store is unavailable, while this callback holds the session lifecycle lock.

Kody rule violation: [Cancel blocking lifecycle work before waiting and bound detached cleanup](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/6bbefdf5-b173-4ab8-aadd-04b9c38df65e?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR. This line comes from #4337 (already merged into main) and shows here only because this PR is stacked on #4363, which still sits on #4337's original commits. This PR's own change is 45fbbde (the move-start rule in handleStart). I'm leaving it unresolved for the maintainers to decide on.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. The flagged cleanup is outside PR #4432’s own changes and originates in the already-merged #4337. Leaving the suggestion unresolved for maintainers to decide on is reasonable.

@Quick104

Copy link
Copy Markdown
Contributor

Thanks for digging into this. I'm closing it because the race in #4364 doesn't happen as described, and the 409 makes the real race worse.

I tested it with two API servers, two transcode nodes, and the session's node stopped while both servers moved the transcode at once.

A remaining gap that predates this PR: with three or more nodes, two servers could each pick a different node. That needs its own issue once it's confirmed.

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

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/XXXL 3000+ added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Two moves of one transcode to the same node can leave it running nothing

2 participants