mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-04 18:09:12 +03:00
[PR #4541] [CLOSED] Optimize database scheduled task #10151
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/jellyfin/jellyfin/pull/4541
Author: @ferferga
Created: 11/22/2020
Status: ❌ Closed
Base:
master← Head:vacuum-task📝 Commits (2)
cfe00daCreate "OptimizeDatabase" scheduled task65a35eeRemove VACUUM at boot time📊 Changes
4 files changed (+106 additions, -5 deletions)
View changed files
📝
Emby.Server.Implementations/Data/BaseSqliteRepository.cs(+0 -3)📝
Emby.Server.Implementations/Localization/Core/en-US.json(+3 -1)📝
Emby.Server.Implementations/Localization/Core/es.json(+3 -1)➕
Emby.Server.Implementations/ScheduledTasks/Tasks/OptimizeDatabase.cs(+100 -0)📄 Description
Before, we ran VACUUM at each start (#1455). Although it solved the problem partially, it isn't the best solution for long-running instances. It also freezes the boot process for a while and it can hang it altogether, in case the filesystem is running out of space.
With a scheduled task, this can be ran periodically at user demand, while also keeping server running in case of any error.
I tested this while running scanning tasks and browsing the library with multiple users and I've never hit any concurrency issue
Additional details
sqlite3cli and issued VACUUM command.I tried multiple combinations of this and nver had a single issue. I read also a lot of the documentation and I got to the conclusion that, as long as there's one connection that handles transactions and one connection that runs vacuum without a transaction, everything is fine atomic-wise. Anyway, I'm leaving library.db as it's going to be deprecated sooner than later and it's better to stay in the safe side.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.