From a1d72deba2cb22006af5e286cc3bb23203ec727f Mon Sep 17 00:00:00 2001 From: JPVenson Date: Wed, 4 Jun 2025 00:15:22 +0300 Subject: Add multiple options for internal locking (#14047) --- .../DatabaseConfigurationOptions.cs | 6 ++++++ .../DatabaseLockingBehaviorTypes.cs | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseLockingBehaviorTypes.cs (limited to 'src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration') diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs index b481a106f..682e5019b 100644 --- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs @@ -9,4 +9,10 @@ public class DatabaseConfigurationOptions /// Gets or Sets the type of database jellyfin should use. /// public required string DatabaseType { get; set; } + + /// + /// Gets or Sets the kind of locking behavior jellyfin should perform. Possible options are "NoLock", "Pessimistic", "Optimistic". + /// Defaults to "NoLock". + /// + public DatabaseLockingBehaviorTypes LockingBehavior { get; set; } } diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseLockingBehaviorTypes.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseLockingBehaviorTypes.cs new file mode 100644 index 000000000..3b2a55802 --- /dev/null +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseLockingBehaviorTypes.cs @@ -0,0 +1,22 @@ +namespace Jellyfin.Database.Implementations.DbConfiguration; + +/// +/// Defines all possible methods for locking database access for concurrent queries. +/// +public enum DatabaseLockingBehaviorTypes +{ + /// + /// Defines that no explicit application level locking for reads and writes should be done and only provider specific locking should be relied on. + /// + NoLock = 0, + + /// + /// Defines a behavior that always blocks all reads while any one write is done. + /// + Pessimistic = 1, + + /// + /// Defines that all writes should be attempted and when fail should be retried. + /// + Optimistic = 2 +} -- cgit v1.2.3