Skip to content

[FIX] auto_database_backup: reset error status on success + clean up leaked temp files#422

Open
GianfrancoNQ wants to merge 1 commit into
CybroOdoo:19.0from
niqera:fix-backup-silent-failure
Open

[FIX] auto_database_backup: reset error status on success + clean up leaked temp files#422
GianfrancoNQ wants to merge 1 commit into
CybroOdoo:19.0from
niqera:fix-backup-silent-failure

Conversation

@GianfrancoNQ

Copy link
Copy Markdown

Fixes #421.

Three fixes in db.backup.configure:

  1. Reset generated_exception = False at the start of each config in _schedule_auto_backup, so a successful backup clears a previous error. Before, it was only written in the except blocks and never cleared, leaving records stuck in error forever.
  2. Add _cleanup_stale_backup_temps() (called at the start of _schedule_auto_backup): sweeps orphan backup temp files (.zip/.dump files and temp dirs containing dump.sql) older than 2h from the temp dir. This prevents leaked NamedTemporaryFile/TemporaryDirectory artifacts (e.g. after a SIGKILL, where context managers don't run) from accumulating until the disk fills.
  3. S3 upload temp file now uses delete=False + try/finally so 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).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] auto_database_backup (19.0): backups silently fail — generated_exception never reset + temp files leak until disk fills

1 participant