Unable to move Main DB to DBTMP: The process cannot access the file
Hi,
There was an error in the powershell. Unable to access the file, despite PMS being stopped when my no doing anything else. Could it be a third party service like Tautulli that access the DB ?
Anyway the bat script worked fine ! thanks for this
2025-01-29 02.02.45 -- ============================================================
2025-01-29 02.02.45 -- Session start: Host is Windows 10 (Build 19045)
2025-01-29 02.02.51 -- Auto - START
2025-01-29 02.02.51 -- Auto - FAIL - PMS running
2025-01-29 02.02.55 -- Stop - START
2025-01-29 02.02.55 -- Stop - PASS
2025-01-29 02.02.58 -- Auto - START
2025-01-29 02.04.13 -- Repair - Export databases - PASS
2025-01-29 02.04.31 -- Repair - Import - PASS
2025-01-29 02.04.34 -- Repair - Verify main database - PASS
2025-01-29 02.04.34 -- Repair - Verify blobs database - PASS
2025-01-29 02.04.34 -- Reindexing Main DB
2025-01-29 02.04.38 -- Reindexing Blobs DB
2025-01-29 02.04.39 -- Reindexing complete.
2025-01-29 02.04.39 -- Moving current DBs to DBTMP and making new databases active
2025-01-29 02.04.39 -- Auto - Unable to move Main DB to DBTMP: The process cannot access the file because it is being used by another process., cannot continue.
2025-01-29 02.04.39 -- Auto - FAIL
2:05:00,38 -- ====== Session begins. (29/01/2025) ======
2:05:00,63 -- Exporting Main DB
2:05:22,29 -- Exporting Blobs DB
2:06:19,14 -- Exporting Complete.
2:06:19,14 -- Creating Main DB
2:06:29,90 -- Verifying Main DB
2:06:32,70 -- Main DB verification check is: ok
2:06:32,70 -- Main DB verification successful.
2:06:32,70 -- Creating Blobs DB
2:06:40,77 -- Verifying Blobs DB
2:06:41,44 -- Blobs DB verification check is: ok
2:06:41,44 -- Blobs DB verification successful.
2:06:41,44 -- Import and verification complete.
2:06:41,44 -- Reindexing Main DB
2:06:44,19 -- Reindexing Blobs DB
2:06:45,25 -- Reindexing complete.
2:06:45,25 -- Moving current DBs to DBTMP and making new databases active
2:06:45,26 -- Database repair/rebuild/reindex completed.
2:06:45,26 -- ====== Session completed. ======
@danrahn
Might you have some time to look into this?
I've never known anything to get in the way unless it's Windows permissions issues .
At a glance I'm not sure what's going on unfortunately. My only initial thought is that the sqlite process used to export the DB is still hanging around for some reason, so by the time we try to move the db, it's still being held by sqlite. I'm away from home over the weekend and my day job has been keeping me busy, but I can try looking into this a bit more at the end of next week.
Might it help to require Plex to be fully stopped (check for processes still running) before starting -or- looping & waiting for it to shut down prior to starting operations?
Yeah, the script does check whether PMS is running beforehand (and the logs show STOP was run, which ends PMS with a 30-second timeout via WaitForExit), but something could have restarted PMS in the ~2 minutes between the start of the script and attempting to move the databases. I can look into also adding checks before any major operation as well, in addition to checking for the Plex SQLite process.
@danrahn
In the Bash code, I have the IsRunning test before every operation
# Check if PMS running
if IsRunning; then
RunState=1
WriteLog "Auto - FAIL - PMS runnning"
Output "Unable to run automatic sequence. PMS is running. Please stop PlexMediaServer."
continue
fi
Perhaps this will work?
@danrahn
Have you had an opportunity to look at this and make a determination?
Sorry, this completely fell off my radar. I'll take a look today, but I'm not able to repro on any of my Windows environments. At the least I'll add checks to ensure PMS (and maybe Plex SQLite) aren't running before moving on to additional operations.
Apologies for the massive delays, things have been a bit hectic here. I still wasn't able to repro this across a couple different Windows environments, so the best I can do here is just make sure Plex isn't running between steps. That seems unlikely to help though if the batch file worked as expected.
@danrahn @paulverbeke
I'm going to close this for now as not-reproducible HOWEVER will gladly reopen if it appears again.
@paulverbeke Please let us know if it recurs
@danrahn
Unrelated to this.
- Name changed to
DBRepairper Trademark Policy - Have pull request I'd like to get your thoughts on.
@ChuckPa thanks for the ping. I'll see if anything needs to be renamed on the Windows side, and take a look at the PR now.