[FIX] auto_database_backup: reset error status on success + clean up leaked temp files#422
Open
GianfrancoNQ wants to merge 1 commit into
Open
[FIX] auto_database_backup: reset error status on success + clean up leaked temp files#422GianfrancoNQ wants to merge 1 commit into
GianfrancoNQ wants to merge 1 commit into
Conversation
…leaked temp files See issue. Three fixes: 1. Reset generated_exception=False at the start of each config so a successful backup clears a previous error (it was only ever written in the except block, leaving records stuck in ERROR forever). 2. Add _cleanup_stale_backup_temps(): sweep orphan backup temp files (>2h) at the start of each run, so leaked NamedTemporaryFile/TemporaryDirectory artifacts (e.g. after a SIGKILL) don't accumulate until the disk fills. 3. S3 upload temp file now uses delete=False + try/finally so it is always removed. Validated in production (Odoo 19): backup uses ~213 MB RAM, ~3.5 min.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #421.
Three fixes in
db.backup.configure:generated_exception = Falseat the start of each config in_schedule_auto_backup, so a successful backup clears a previous error. Before, it was only written in theexceptblocks and never cleared, leaving records stuck in error forever._cleanup_stale_backup_temps()(called at the start of_schedule_auto_backup): sweeps orphan backup temp files (.zip/.dumpfiles and temp dirs containingdump.sql) older than 2h from the temp dir. This prevents leakedNamedTemporaryFile/TemporaryDirectoryartifacts (e.g. after a SIGKILL, where context managers don't run) from accumulating until the disk fills.delete=False+try/finallyso it is always removed, even if the upload fails.Validated on Odoo 19 in production: backup uses ~213 MB RSS and ~3.5 min for a 2.3 GB zip; status now clears on success and no temp files are left behind.
Contributed by NIQERA (https://niqera.com).