sqlite "database is locked" during DB dump was logged but not retried and run completed (no alert) #1223
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?
What I'm trying to do and why
Hi!
I run borgmatic with database dump hooks (postgres + sqlite) as part of an automated full-system backup.
I discovered a sqlite lock error in the logs but the service finished successfully and healthchecks/uptime notifications indicated success, so I was not alerted.
It'd be nice if errors during dumps were retried (for transients) and/or alerted us!
Steps to reproduce
This is unfortunately not reliably reproducible for me.
I encountered this while inspecting logs after a scheduled run, but running the service manually multiple times didn't show the issue again.
This relevant excerpt from the config:
Actual behavior
borgmaticlogged the sqlite lock error, did not appear to retry, continued processing (archive rename/prune/compact), reported success to healthchecks/uptime, and systemd showed the service as deactivated successfully.Expected behavior
One of these (or both) would be preferable:
Either change would surface the problem to the operator instead of allowing a silent miss while healthchecks/notifications indicate success!
Other notes / implementation ideas
No response
borgmatic version
2.0.13
borgmatic installation method
NixOs
Borg version
borg 1.4.3
Python version
Python 3.13.11
Database version (if applicable)
sqlite 3.50.4 2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45e20a3 (64-bit)
Operating system and version
BUILD_ID="25.11.2679.9ef261221d1e" CPE_NAME="cpe:/o:nixos:nixos:25.11" ID=nixos PRETTY_NAME="NixOS 25.11 (Xantusia)" VERSION="25.11 (Xantusia)" VERSION_CODENAME=xantusia VERSION_ID="25.11"
Happy to provide more information, logs or context!
Thanks a lot for borgmatic!
Thanks for the detailed ticket. Some points on this:
--verbosity 2? I'm particularly interested in the SQLite command that borgmatic is issuing. Does it contain the-bailflag?It does!
Reproduced with the lock!
(A couple more failures here than on the original, because I created an external lock and prevented healthchecks itself from using its own database)
Another reproduction but with
--verbosity 2Super odd! What happens if you run SQLite manually while the database is locked? Example:
Does that command exit with an error or not? (
echo $?in bash)It does not exit with an error:
Oh, an sqlite bug was not my bingo card given their track record!
I guess I was just very very unlucky - it was recently solved but is probably not yet released
https://sqlite.org/forum/forumpost/a4f3873b0a8503ccd62b29491de01c13ca8f764a52c6032f8873802bd474caba
https://sqlite.org/src/info/850b92b634718
Thanks for holding my hand throughout this!
Wow, good find! Yeah, borgmatic gets all of its cues on database dump success from SQLite's exit code. So if it happily blunders through and returns success despite an error, so does borgmatic. 😄
FWIW, I do have a newer version of SQLite that apparently isn't manifesting this bug. Maybe it's not available in NixOS yet though.
Tested with 3.51.1 on nixos-unstable and we're back on track! Thanks again!
Awesome, glad to hear it!