fix(ha): gate the remaining timer-driven scheduled tasks #28
Reference in New Issue
Block a user
Delete Branch "benvin/gated-task-keys"
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?
Seven timer-driven tasks were left out of the scan-leader gate, so every replica ran lyric and subtitle downloads, TMDb upcoming-episode refreshes, trickplay generation, live TV channel and guide refreshes and plugin updates on its own timer: duplicate ffmpeg work, third-party API quota burned N times over, racing row writes and concurrent assembly writes into a shared /config/plugins. MoveTrickplayImages has no default trigger but needs the same gate once an operator schedules it.
Closes #14
DefaultGatedTaskKeys_Should_MatchRegisteredScheduledTasksonly checksGatedTaskKeys.Except(registeredKeys)(gated keys exist as real tasks), never the reverse. Verified by deleting"DownloadLyrics"fromScanLeaderOptions.GatedTaskKeysand rerunning: both tests still pass. This PRs actual fix (the 8 new keys) is not pinned by any test — a future revert of this change would go undetected → assert the gated set against a known/expected list (or assert specific keys are present), not just non-emptiness of the Except.GetDefaultTriggers() => []; this task has no periodic trigger, so it does not actually "fire on every replica" as the PR body claims. Gating it is harmless but the stated rationale for including this key is inaccurate.nit: MediaBrowser.Controller/ScheduledTasks/ScanLeaderOptions.cs:54 — gating "PluginUpdates" also silently disables its
StartupTrigger(Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs:62):ScheduledTaskWorker.OnTriggerTriggeredre-arms a gated-and-skipped trigger withisApplicationStartup: false, andStartupTrigger.Startonly fires when that flag is true, so a replica that is not leader at its own boot never gets a startup-triggered plugin-update check again for its process lifetime, silently falling back to the 24h interval trigger → call this out as intended behaviour or add a test for it.