Skip to content

supabase_backup.py: no retention on pg finals — R2 pg/ prefixes grow unbounded by design #3915

Closed

Description

@dezren39

supabase_backup.py: no retention on pg finals — R2 pg/ prefixes grow unbounded by design

Found during the 2026-11-01 R2 review (laptop ~/tools/supabase-backup/supabase_backup.py; canonical copy lives with the laptop backup tooling).

Current state (measured). R2 supabase-backups/pg/ = 22 objects, 172 MB:

  • pg/muse-dev/ — 18 objects, 123.8 MB, 2026-10-21 → 2026-10-30 (legacy writer, frozen when the job moved to the laptop).
  • pg/muse-dev2/ — 4 objects, 48.1 MB, current writer (12h cadence via --if-due + manifest).

The gap. The writer is content-addressed (pg/<project>/YYYY/MM/<sha256>.<kind>.zst) with dedupe on identical dumps and a manifest — all good — but nothing in the script ever deletes a stored final or prunes the manifest. Every changed dump is kept forever. Latest finals run 15–20 MB and the database keeps growing, so the prefix's growth rate only increases (currently ~16 MB/day ≈ 0.5 GB/month, small today, unbounded forever).

Ask. Declare a retention for pg finals (e.g. keep last N per project + a time bound, in the manifest-driven style the script already uses — delete the object and drop the manifest entry together), and apply it to the legacy pg/muse-dev/ prefix too (its manifest is frozen; either adopt it under the same retention or record the decision to keep it as a frozen archive). Also: orphaned staging keys are deleted on success but not on crash — a periodic staging sweep (keys under */staging/ older than 24h) would have caught the 2026-10-27 leftover (10.8 MB) that the R2 review removed by hand.

Acceptance criteria

  • A retention rule for pg finals is declared in supabase_backup.py (last-N per project plus a time bound, in the manifest-driven style the script already uses): expiring a final deletes the R2 object and drops its manifest entry together.
  • The legacy pg/muse-dev/ prefix is either adopted under the same retention or explicitly recorded in the script/manifest as a frozen archive.
  • A periodic staging sweep deletes */staging/ keys older than 24h, including after a crashed run.
  • Verified by an R2 listing after a run: the pg/ prefixes no longer grow unbounded and no staging keys older than 24h remain.

Activity

  1. added
    kind/infrastructureInfrastructure / host-portability work
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    area/infraInfrastructure, deployment, and operations
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 1, 2026
  2. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    Intake review

    Related: code issue #3860 / #3859 / #3858 (same 2026-11-01 R2 review series: staging leaks, repo-archive duplication, payload retention).

    Notes: Measured today: supabase-backups/pg/ = 22 objects / 172 MB, growing ~16 MB/day and accelerating with database size. The writer's content-addressing and manifest are sound; only deletion is missing.

    Risks: Retention deletes backup data — the keep-N + time bound must be chosen so the oldest retained final still covers the recovery window the other backup legs assume. Applying retention to the frozen legacy prefix is a one-way delete; the frozen-archive alternative must be an explicit recorded decision, not a default.

    Suggested approach: Add a manifest-driven prune step to supabase_backup.py (finals + staging sweep in the same pass), dry-run it against the current manifest first, and record the chosen N / time bound in the script where the next reviewer will see it.

    — fleet monitor intake enrichment, 2026-11-01 run (protocol §5). Acceptance criteria appended to the body where missing; labels normalized.

  3. added
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 3, 2026
  4. developing-today commented on Nov 3, 2026

    @developing-today
    Contributor

    agent-note:v1
    state: triaged (coverage pass)
    Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 40 (priority/normal). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
    Found via: coverage pass 2026-11-03

  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 3, 2026
  6. 19 remaining items

  7. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · blocked pending Drew authorization

    Claimed task 8713 and revalidated #3915. The issue remains open, assigned to Drew, with user/escalated, queue/blocked, and status/blocked. The packet targets /home/user/hatch-personal, outside this code-only lane; that checkout has extensive pre-existing untracked work, so I did not touch it. The queue task is blocked until Drew resolves the escalation and confirms the intended cross-repository target.

  8. added and removed
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    on Nov 14, 2026
  9. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Released to the queue under Drew's 2026-11-13 unblock-all order (main chat, 23:53 CT). Task(s) 8713 moved from blocked/parked to queued in the fleet unblock-all pass (worker main-unblock-all-2026-11-13). Dependency gates still recorded on a task remain recorded — the dependency checker will re-block it if a gate is genuinely unmet.

  10. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 14, 2026
  11. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    task: 8713
    lane: code-b
    summary: Fixed and merged. supabase_backup.py now declares and applies pg-final retention (keep newest 14 per project + everything younger than retention_days=90; expire only beyond BOTH bounds, deleting the R2 object and dropping its manifest entry together), runs a staging sweep deleting pg/*/staging/ keys older than 24h (including crashed-run leftovers), and records the legacy pg/muse-dev/ prefix as a frozen archive (FROZEN_PREFIXES, never pruned). Both run after every stored backup and standalone via --retention [--dry-run]. Landed as dezren39/hatch-personal PR #51, merged 27548dc8f59cc1adbf421ba50a83702b211c86f5; the laptop primary checkout was fast-forwarded to the merge, so the scheduled job runs the new code. Note on the old escalation: the pending-decisions ledger records this gate as RELEASED (fleet edits hatch-personal via PRs routinely; no Drew gate), and user/escalated is a fleet-applied label, not a hold — work proceeded under the runbook.
    evidence:

    • Fake-S3 harness (oracle: hand-computed expectations): retention rank/age boundaries (exactly-90d kept; expiry needs rank >= 14 AND age > 90d), staging age filter across prefixes, dry-run deletes nothing and writes no manifest, apply deletes objects + drops entries + writes manifest once — all pass, re-verified after the rebase cherry-pick (e0d247e0f).
    • Live dry-run then live apply, 2026-11-14: {"status": "retention_applied", "prefix": "pg/muse-dev2", "frozen_prefixes": ["pg/muse-dev/"], "retention": {"kept": 13, "expired": 0, "keep_last": 14, "max_age_days": 90}, "staging_sweep": {"stale_staging_deleted": 0, "max_age_hours": 24}}.
    • R2 listing after the run (manifest): pg/muse-dev2 = 13 finals, 2026-10-30 → 2026-11-13, 437.3 MB total, no staging keys older than 24h anywhere under pg/ (the sweep lists the whole pg/ tree). Growth is now capped by the rule: at the 12h cadence at most 14 finals plus 90 days of changed dumps per project.
      next: none. Closing this issue per its acceptance criteria.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/infraInfrastructure, deployment, and operationseffort/sSmall: expected under 2 hours of workepic/storageEpic: epic/storage (fleet reprioritization 2026-11-12)kind/infrastructureInfrastructure / host-portability workmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this itemuser/escalatedRequires a Drew decision or access

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions