fix(ha): gate library tasks on the scan leader by default
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

Jellyfin:ScanLeader:Enabled defaults to false and nothing sets it, so
leader election never runs and every replica executes the timer-driven
library tasks concurrently - the exact behaviour the lease prevents.

- Enable gating by default when a Redis connection string is configured
- Honour an explicit Enabled setting either way
- Carry the effective decision onto the bound options the task worker reads
- Log at startup whether gating is active
- Warn when gating is enabled but no Redis connection string is configured
This commit is contained in:
2026-09-13 13:19:48 +10:00
parent 25269263ce
commit 91655fcb0a
5 changed files with 242 additions and 15 deletions
@@ -6,9 +6,20 @@ namespace MediaBrowser.Controller.ScheduledTasks;
/// </summary>
public sealed class ScanLeaderOptions
{
/// <summary>
/// The configuration section these options bind from.
/// </summary>
public const string ConfigurationSection = "Jellyfin:ScanLeader";
/// <summary>
/// The configuration key that overrides the default enablement.
/// </summary>
public const string EnabledKey = ConfigurationSection + ":Enabled";
/// <summary>
/// Gets or sets a value indicating whether scan-leader election is enabled. When disabled,
/// every instance runs its periodic tasks as before.
/// every instance runs its periodic tasks as before. Left unset, election is enabled whenever a
/// Redis connection string is configured, because that is the only deployment shape that needs it.
/// </summary>
public bool Enabled { get; set; }