DeviceId writes device.txt non-atomically on a shared volume #24
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context: multi-replica stateless deployment (two 2-replica apps,
cheeztvandfafflix, each one PostgreSQL plus valkey, no sticky sessions). Not a 12.0 regression — live in the deployed build. Tracking: #12.Problem
Emby.Server.Implementations/Devices/DeviceId.cspersists the generated id todevice.txton the shared/configvolume with a plainFile.WriteAllText, and memoises the value it read.Two pods doing first boot simultaneously can interleave that write, leaving a truncated or mixed file. A pod that read the partial value then serves a wrong
SystemIdfor its whole lifetime, because the value is memoised.Low impact and rare — but the window exists on every fresh deployment, and the fix is a one-liner.
Proposal
Write to a temporary file on the same filesystem and
File.Moveit into place with overwrite, so a reader only ever sees a complete value. Memoisation is fine once the write is atomic; no need for a watcher.Acceptance