danieladov / jellyfin-plugin-mergeversions

This plugin scans all your movies and groups every repeated movie in one version
MIT License
185 stars 13 forks source link

Merge movies error 'database is locked' crashes the server #57

Open hinsky opened 1 month ago

hinsky commented 1 month ago

Hi Daniel, I have my Jellyfin clear installed in docker, merging episodes were all ok. The error shows up in 2~3 minutes when merging movies, and crashes the Jellyfin to reboot

thanks

[2024-06-02 10:31:05.895 +08:00] [INF] [40] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Spliting ***
[2024-06-02 10:31:06.065 +08:00] [INF] [13] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Spliting ***
[2024-06-02 10:31:06.111 +08:00] [INF] [39] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Spliting ***
[2024-06-02 10:31:06.084 +08:00] [FTL] [113] Main: Unhandled Exception
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 5: 'database is locked'.
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteConnectionExtensions.ExecuteNonQuery(SqliteConnection connection, String commandText, SqliteParameter[] parameters)
   at Microsoft.Data.Sqlite.SqliteTransaction..ctor(SqliteConnection connection, IsolationLevel isolationLevel, Boolean deferred)
   at Emby.Server.Implementations.Data.SqliteItemRepository.SaveImages(BaseItem item)
   at Emby.Server.Implementations.Library.LibraryManager.UpdateImagesAsync(BaseItem item, Boolean forceUpdate)
   at Emby.Server.Implementations.Library.LibraryManager.RunMetadataSavers(BaseItem item, ItemUpdateType updateReason)
   at Emby.Server.Implementations.Library.LibraryManager.UpdateItemsAsync(IReadOnlyList`1 items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
   at MediaBrowser.Controller.Entities.Video.UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationToken)
   at Jellyfin.Plugin.MergeVersions.MergeVersionsManager.DeleteAlternateSources(Guid itemId)
   at Jellyfin.Plugin.MergeVersions.MergeVersionsManager.<>c__DisplayClass7_0.<<SplitMovies>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
[2024-06-02 10:31:06.174 +08:00] [INF] [17] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Spliting ***
[2024-06-02 10:31:15.964 +08:00] [INF] [1] Main: Jellyfin version: "10.9.3"
[2024-06-02 10:31:15.994 +08:00] [INF] [1] Main: Environment Variables: ["[JELLYFIN_WEB_DIR, /jellyfin/jellyfin-web]", "[JELLYFIN_DATA_DIR, /config]", "[JELLYFIN_CACHE_DIR, /cache]", "[JELLYFIN_CONFIG_DIR, /config/config]", "[JELLYFIN_FFMPEG, /usr/lib/jellyfin-ffmpeg/ffmpeg]", "[JELLYFIN_LOG_DIR, /config/log]"]
[2024-06-02 10:31:15.996 +08:00] [INF] [1] Main: Arguments: ["/jellyfin/jellyfin.dll", "--ffmpeg", "/usr/lib/jellyfin-ffmpeg/ffmpeg"]
[2024-06-02 10:31:15.996 +08:00] [INF] [1] Main: Operating system: "Debian GNU/Linux 12 (bookworm)"
[2024-06-02 10:31:15.996 +08:00] [INF] [1] Main: Architecture: X64
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: 64-Bit Process: True
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: User Interactive: True
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: Processor count: 4
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: Program data path: "/config"
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: Log directory path: "/config/log"
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: Config directory path: "/config/config"
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: Cache path: "/cache"
[2024-06-02 10:31:15.997 +08:00] [INF] [1] Main: Web resources path: "/jellyfin/jellyfin-web"
[2024-06-02 10:31:15.998 +08:00] [INF] [1] Main: Application directory: "/jellyfin/"
[2024-06-02 10:31:16.148 +08:00] [INF] [1] Emby.Server.Implementations.AppBase.BaseConfigurationManager: Setting cache path: "/cache"
[2024-06-02 10:31:16.216 +08:00] [INF] [1] Emby.Server.Implementations.ApplicationHost: Loading assemblies
[2024-06-02 10:31:16.235 +08:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.MergeVersions, Version=10.9.1.1, Culture=neutral, PublicKeyToken=null" from "/config/plugins/Merge Versions_10.9.1.1/Jellyfin.Plugin.MergeVersions.dll"
[2024-06-02 10:31:16.297 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Defined LAN subnets: ["::1/128", "fe80::/10", "fc00::/7", "127.0.0.1/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
[2024-06-02 10:31:16.297 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Defined LAN exclusions: []
[2024-06-02 10:31:16.298 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Used LAN subnets: ["::1/128", "fe80::/10", "fc00::/7", "127.0.0.1/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
danieladov commented 3 weeks ago

Hi, can you confirm this also happens with jellyfin's latest version ( 10.9.6 )?

slimshizn commented 2 weeks ago

Hi, can you confirm this also happens with jellyfin's latest version ( 10.9.6 )?

Still does happen on latest release as well.

hinsky commented 2 weeks ago

Hi, can you confirm this also happens with jellyfin's latest version ( 10.9.6 )?

No reboot during the merging/spliting now, but crashed after the process finished when refreshing the jellyfin page...

[2024-06-16 09:23:07.265 +08:00] [INF] [87] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Spliting XXX
[2024-06-16 09:23:07.849 +08:00] [INF] [13] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Completed
[2024-06-16 09:23:39.409 +08:00] [INF] [86] Emby.Server.Implementations.Session.SessionWebSocketListener: Sending ForceKeepAlive message to 1 inactive WebSockets.
[2024-06-16 09:24:27.409 +08:00] [INF] [86] Emby.Server.Implementations.Session.SessionWebSocketListener: Sending ForceKeepAlive message to 1 inactive WebSockets.
[2024-06-16 09:25:32.859 +08:00] [WRN] [416] Emby.Server.Implementations.HttpServer.WebSocketConnection: WS "192.168.3.3" error receiving data: "The remote party closed the WebSocket connection without completing the close handshake."
[2024-06-16 09:25:32.859 +08:00] [WRN] [431] Emby.Server.Implementations.HttpServer.WebSocketConnection: WS "192.168.3.3" error receiving data: "The remote party closed the WebSocket connection without completing the close handshake."
[2024-06-16 09:25:32.862 +08:00] [INF] [416] Emby.Server.Implementations.HttpServer.WebSocketManager: WS "::ffff:192.168.3.3" closed
[2024-06-16 09:25:32.862 +08:00] [INF] [431] Emby.Server.Implementations.HttpServer.WebSocketManager: WS "::ffff:192.168.3.3" closed
[2024-06-16 09:25:32.868 +08:00] [FTL] [416] Main: Unhandled Exception
System.NullReferenceException: Object reference not set to an instance of an object.
   at Emby.Server.Implementations.Session.WebSocketController.<>c.<GetActiveSockets>b__12_0(IWebSocketConnection i)
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at System.Linq.Enumerable.<Any>g__WithEnumerator|36_0[TSource](IEnumerable`1 source)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
   at Emby.Server.Implementations.Session.WebSocketController.get_HasOpenSockets()
   at Emby.Server.Implementations.Session.WebSocketController.get_IsSessionActive()
   at Emby.Server.Implementations.Session.SessionManager.<>c.<CloseIfNeededAsync>b__52_0(ISessionController i)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Emby.Server.Implementations.Session.SessionManager.CloseIfNeededAsync(SessionInfo session)
   at Emby.Server.Implementations.Session.WebSocketController.OnConnectionClosed(Object sender, EventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
[2024-06-16 09:25:32.868 +08:00] [FTL] [429] Main: Unhandled Exception
System.NullReferenceException: Object reference not set to an instance of an object.
   at Emby.Server.Implementations.Session.WebSocketController.<>c.<GetActiveSockets>b__12_0(IWebSocketConnection i)
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at System.Linq.Enumerable.<Any>g__WithEnumerator|36_0[TSource](IEnumerable`1 source)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
   at Emby.Server.Implementations.Session.WebSocketController.get_HasOpenSockets()
   at Emby.Server.Implementations.Session.WebSocketController.get_IsSessionActive()
   at Emby.Server.Implementations.Session.SessionManager.<>c.<CloseIfNeededAsync>b__52_0(ISessionController i)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Emby.Server.Implementations.Session.SessionManager.CloseIfNeededAsync(SessionInfo session)
   at Emby.Server.Implementations.Session.WebSocketController.OnConnectionClosed(Object sender, EventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
[2024-06-16 09:25:37.535 +08:00] [INF] [1] Main: Jellyfin version: "10.9.6"
[2024-06-16 09:25:37.565 +08:00] [INF] [1] Main: Environment Variables: ["[JELLYFIN_WEB_DIR, /jellyfin/jellyfin-web]", "[JELLYFIN_DATA_DIR, /config]", "[JELLYFIN_LOG_DIR, /config/log]", "[JELLYFIN_CACHE_DIR, /cache]", "[JELLYFIN_FFMPEG, /usr/lib/jellyfin-ffmpeg/ffmpeg]", "[JELLYFIN_CONFIG_DIR, /config/config]"]
[2024-06-16 09:25:37.567 +08:00] [INF] [1] Main: Arguments: ["/jellyfin/jellyfin.dll", "--ffmpeg", "/usr/lib/jellyfin-ffmpeg/ffmpeg"]
[2024-06-16 09:25:37.567 +08:00] [INF] [1] Main: Operating system: "Debian GNU/Linux 12 (bookworm)"
[2024-06-16 09:25:37.567 +08:00] [INF] [1] Main: Architecture: X64
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: 64-Bit Process: True
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: User Interactive: True
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Processor count: 3
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Program data path: "/config"
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Log directory path: "/config/log"
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Config directory path: "/config/config"
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Cache path: "/cache"
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Web resources path: "/jellyfin/jellyfin-web"
[2024-06-16 09:25:37.568 +08:00] [INF] [1] Main: Application directory: "/jellyfin/"
[2024-06-16 09:25:37.708 +08:00] [INF] [1] Emby.Server.Implementations.AppBase.BaseConfigurationManager: Setting cache path: "/cache"
[2024-06-16 09:25:37.779 +08:00] [INF] [1] Emby.Server.Implementations.ApplicationHost: Loading assemblies
[2024-06-16 09:25:37.799 +08:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.MergeVersions, Version=10.9.1.1, Culture=neutral, PublicKeyToken=null" from "/config/plugins/Merge Versions_10.9.1.1/Jellyfin.Plugin.MergeVersions.dll"
[2024-06-16 09:25:37.871 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Defined LAN subnets: ["::1/128", "fe80::/10", "fc00::/7", "127.0.0.1/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
[2024-06-16 09:25:37.872 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Defined LAN exclusions: []
[2024-06-16 09:25:37.872 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Used LAN subnets: ["::1/128", "fe80::/10", "fc00::/7", "127.0.0.1/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
[2024-06-16 10:54:52.058 +08:00] [INF] [79] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: Merging XXX
[2024-06-16 10:54:52.704 +08:00] [INF] [71] Jellyfin.Plugin.MergeVersions.MergeVersionsManager: All movies merged
[2024-06-16 10:54:52.704 +08:00] [INF] [71] Emby.Server.Implementations.ScheduledTasks.TaskManager: "Merge All Movies" Completed after 9 minute(s) and 47 seconds
[2024-06-16 10:56:35.891 +08:00] [INF] [71] Emby.Server.Implementations.Session.SessionWebSocketListener: Sending ForceKeepAlive message to 1 inactive WebSockets.
[2024-06-16 10:59:23.891 +08:00] [INF] [346] Emby.Server.Implementations.Session.SessionWebSocketListener: Sending ForceKeepAlive message to 1 inactive WebSockets.
[2024-06-16 11:01:33.737 +08:00] [INF] [341] Jellyfin.Server.Implementations.Users.UserManager: Authentication request for "wbp" has succeeded.
[2024-06-16 11:01:33.737 +08:00] [INF] [341] Emby.Server.Implementations.Session.SessionManager: Current/Max sessions for user "wbp": 1/0
[2024-06-16 11:01:33.738 +08:00] [INF] [341] Emby.Server.Implementations.Session.SessionManager: Logging out access token "8522969d3f0b4886bf9845c4b929e691"
[2024-06-16 11:01:33.746 +08:00] [INF] [341] Emby.Server.Implementations.Session.SessionManager: Creating new access token for user de9ebebc-a410-4357-9257-3918a9680cda
[2024-06-16 11:02:21.402 +08:00] [INF] [1] Main: Jellyfin version: "10.9.6"
[2024-06-16 11:02:21.436 +08:00] [INF] [1] Main: Environment Variables: ["[JELLYFIN_WEB_DIR, /jellyfin/jellyfin-web]", "[JELLYFIN_FFMPEG, /usr/lib/jellyfin-ffmpeg/ffmpeg]", "[JELLYFIN_LOG_DIR, /config/log]", "[JELLYFIN_CACHE_DIR, /cache]", "[JELLYFIN_DATA_DIR, /config]", "[JELLYFIN_CONFIG_DIR, /config/config]"]
[2024-06-16 11:02:21.438 +08:00] [INF] [1] Main: Arguments: ["/jellyfin/jellyfin.dll", "--ffmpeg", "/usr/lib/jellyfin-ffmpeg/ffmpeg"]
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Operating system: "Debian GNU/Linux 12 (bookworm)"
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Architecture: X64
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: 64-Bit Process: True
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: User Interactive: True
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Processor count: 3
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Program data path: "/config"
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Log directory path: "/config/log"
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Config directory path: "/config/config"
[2024-06-16 11:02:21.439 +08:00] [INF] [1] Main: Cache path: "/cache"
[2024-06-16 11:02:21.440 +08:00] [INF] [1] Main: Web resources path: "/jellyfin/jellyfin-web"
[2024-06-16 11:02:21.440 +08:00] [INF] [1] Main: Application directory: "/jellyfin/"
[2024-06-16 11:02:21.583 +08:00] [INF] [1] Emby.Server.Implementations.AppBase.BaseConfigurationManager: Setting cache path: "/cache"
[2024-06-16 11:02:21.651 +08:00] [INF] [1] Emby.Server.Implementations.ApplicationHost: Loading assemblies
[2024-06-16 11:02:21.669 +08:00] [INF] [1] Emby.Server.Implementations.Plugins.PluginManager: Loaded assembly "Jellyfin.Plugin.MergeVersions, Version=10.9.1.1, Culture=neutral, PublicKeyToken=null" from "/config/plugins/Merge Versions_10.9.1.1/Jellyfin.Plugin.MergeVersions.dll"
[2024-06-16 11:02:21.739 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Defined LAN subnets: ["::1/128", "fe80::/10", "fc00::/7", "127.0.0.1/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
[2024-06-16 11:02:21.739 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Defined LAN exclusions: []
[2024-06-16 11:02:21.739 +08:00] [INF] [1] Jellyfin.Networking.Manager.NetworkManager: Used LAN subnets: ["::1/128", "fe80::/10", "fc00::/7", "127.0.0.1/8", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]