91655fcb0a
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
49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
namespace MediaBrowser.Controller.ScheduledTasks;
|
|
|
|
/// <summary>
|
|
/// Configuration options for scan-leader election, which gates periodic library-mutating
|
|
/// scheduled tasks to a single leader instance in a multi-pod deployment.
|
|
/// </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. 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; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the duration in seconds for which the scan-leader lease is held before it must
|
|
/// be renewed. A leader that stops renewing loses the lease after this duration.
|
|
/// </summary>
|
|
public int LeaseDurationSeconds { get; set; } = 60;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the set of scheduled task keys whose periodic (timer-driven) execution is gated
|
|
/// to the scan leader. Tasks not listed here run on every instance, and manual or API-triggered
|
|
/// runs are never gated.
|
|
/// </summary>
|
|
public string[] GatedTaskKeys { get; set; } =
|
|
{
|
|
"RefreshLibrary",
|
|
"RefreshPeople",
|
|
"RefreshChapterImages",
|
|
"AudioNormalization",
|
|
"TaskExtractMediaSegments",
|
|
"KeyframeExtraction",
|
|
"CleanupUserDataTask",
|
|
"OptimizeDatabaseTask"
|
|
};
|
|
}
|