Run Repo vacuum via Oban scheduled job

This way if there's any resource contention to obtain a db connection,
Oban can manage retries.
This commit is contained in:
Claudio Ortolina
2025-10-25 10:21:21 +01:00
parent 4c65bbddb6
commit af8ca54d3e
2 changed files with 13 additions and 1 deletions
+3 -1
View File
@@ -85,7 +85,9 @@ config :music_library, Oban,
crontab: [
# every 12 hours
{"0 */12 * * *", MusicLibrary.Worker.ApplyScrobbleRules},
{"0 */12 * * *", MusicLibrary.Worker.PruneAssetCache}
{"0 */12 * * *", MusicLibrary.Worker.PruneAssetCache},
# every day at 3 am,
{"0 3 * * *", MusicLibrary.Worker.RepoVacuum}
]}
]
+10
View File
@@ -0,0 +1,10 @@
defmodule MusicLibrary.Worker.RepoVacuum do
use Oban.Worker, queue: :heavy_writes, max_attempts: 3
require Logger
@impl Oban.Worker
def perform(_) do
MusicLibrary.Repo.vacuum()
end
end