Skip to content

supabase backups: staging uploads leak incomplete multipart uploads; staging never reconciled #3860

Open

Description

@dezren39

Finding (R2 review, 2026-11-01)

The Supabase backup staging uploads (supabase-backups bucket, pg/muse-dev/staging/ prefix, written by supabase_backup.py from the laptop) leak incomplete multipart uploads when an upload fails or is interrupted: the staging object is retried under a new key and the failed upload is never aborted.

Evidence: 6 orphaned multipart uploads found initiated 2026-10-26 → 2026-10-30 (2 with one 8 MiB part each uploaded, 4 with no parts — 16 MiB of stored parts total). All 6 were aborted during the 2026-11-01 review and the bucket verified back to 0 incomplete uploads. Separately, one completed staging object (pg/muse-dev/staging/f4b085ed-….api.jsonl.zst, 10.8 MB, 2026-10-27) was left behind in staging. It is not accounted for: its sha256 (5d38249d…, computed during the review) appears neither in pg/muse-dev/manifest.json nor as a final hash-named object, so it may be the only copy of that export — the review left it untouched. Staging is neither cleaned nor reconciled after a run.

The byte cost today is trivial; the defect is that failed runs accumulate invisible state in the bucket (multipart parts don't show in normal object listings) and the staging prefix silently diverges from "empty between runs".

Ask

  • In supabase_backup.py: abort the multipart upload on any failure path (S3 AbortMultipartUpload); on success, finalize the staging object (hash-name + manifest entry) or remove it — and reconcile the one already stranded (f4b085ed-…, sha256 5d38249dd92d15b07beb039e4933125a1cee00b50bd4a1b0167e670555c154e1): land it in the manifest if it is a real backup, since right now it is an unaccounted possible-only-copy.
  • Independently, as a bucket-level backstop: add an R2 lifecycle rule on supabase-backups aborting incomplete multipart uploads after e.g. 7 days, so any writer's orphans self-clean.

Acceptance criteria

  • supabase_backup.py aborts its multipart upload (S3 AbortMultipartUpload) on every failure/interruption path, so a failed run leaves zero incomplete multipart uploads in supabase-backups (verified by listing incomplete uploads after a deliberately failed run).
  • On success, the staging object is finalized (hash-named + manifest entry) or removed; the pg/muse-dev/staging/ prefix is empty between runs.
  • The stranded staging object f4b085ed-… (sha256 in the finding above) is reconciled: landed in the manifest if it is a real backup, or given a documented disposition — it is not deleted before that check, since it may be the only copy of that export.
  • A bucket-level backstop exists: an R2 lifecycle rule on supabase-backups aborts incomplete multipart uploads after ~7 days, verified in the bucket configuration.

Activity

  1. added
    kind/bug
    status/needs-triage
    priority/normal
    effort/s
    area/infra
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Intake review

    • Related: repo-archive stored twice in R2 (~24 GB): raw bundle/tar pass + daily restic of a static directory #3859 and webhook-gateway-payloads: no retention — R2 payload bucket grows unboundedly (~+9k objects/day) #3858 (same 2026-11-01 R2 review, same supabase-backups bucket family); no merged PR or commit since the review resolves this — the 6 orphans found were already aborted during the review itself, so the live defect is the missing abort/reconcile code path, not current debris.
    • Notes: The byte cost today is trivial; the real risk is invisible state (multipart parts do not appear in normal object listings) plus the one stranded completed object, which may be the only copy of a 2026-10-27 export.
    • Risks: Deleting or ignoring the stranded f4b085ed-… object before reconciling it against the manifest could destroy the sole copy of that export. The lifecycle backstop must only abort incomplete uploads, never completed objects.
    • Suggested approach: Fix the writer first (abort on failure, finalize-or-remove on success, reconcile the stranded object), then add the 7-day lifecycle backstop so any writer's orphans self-clean.
  3. added
    meta/enriched
    queue/queued
    source/creator
    task/triage
    on Nov 2, 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/assigned
    and removed
    status/needs-triage
    queue/queued
    on Nov 3, 2026
  6. 103 remaining items

  7. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Progress (Felix lane, 2026-11-29): the criterion-1 code slice is landed as dezren39/hatch-personal PR #153 (unmerged, for review) — stage_upload() extraction + abort guard covering the spawn-failure, dedupe-head-failure, and interruption escapes the inline flow leaked; 7 new FakeS3 tests pass, existing 12 stay green. Note in laptop/tools/supabase-backup/.

    Still open on #3860 after #153 merges: criterion 3 (live reconciliation of the stranded f4b085ed-… object — the --reconcile-staging command exists since slice 1; the live run against the bucket has not been recorded) and criterion 4 (R2 lifecycle backstop on supabase-backups). Both are live-infra steps, not code.

  8. dezren39 commented on Nov 29, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · census 2026-11-29 (lane CEN-C03)

    Census verified: status/ready is accurate. Fully evidenced bug — 6 orphaned multipart uploads found and aborted 2026-11-01, plus one stranded staging object whose sha256 is recorded in the body. The ask is precise: abort-on-failure in supabase_backup.py, reconcile the stranded object into the manifest, and add the R2 lifecycle backstop. Blocker: none. Priority: normal (unchanged).

  9. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Census 2026-11-29 (Felix): full recheck of this issue (body, all 39 comments, labels, dependency edges).

    STRENGTHS: One of the best-evidenced bug reports in the repo — the finding names the bucket, prefix, the six orphaned multipart uploads (all aborted during the review itself), and the stranded completed object with its full sha256, plus four checkable acceptance criteria. The long triage history converged correctly: repeated fresh checks established the writer is NOT in this repo (no supabase_backup.py anywhere in developing-today/code), and the 2026-11-27 decision routed the work to the owning repo, dezren39/hatch-personal, with the stranded object protected from deletion until hash-checked.

    GAPS: The trail after routing is split across two repos, so a cold reader here can miss the current state. Recording it in one place: slice 1 (crash-safe finalize + staging reconcile) landed as hatch-personal PR #128, MERGED 2026-11-28; the criterion-1 completion slice (stage_upload abort guard) landed as hatch-personal PR #153, MERGED 2026-11-29. Neither fact was stated on this issue after the merges.

    FIXES I APPLIED: None to labels — priority/normal fits (tiny byte cost, real but bounded integrity risk), kind/bug is correct, status/ready remains fair for the two live steps below. No blocker edges: nothing blocks this issue; its remainder is scheduled live work, not a dependency.

    REMAINS: Two acceptance criteria are live-infra steps, not code: (3) run the live reconciliation of the stranded f4b085ed-... staging object (the --reconcile-staging path now exists; hash-check against the manifest before any disposition — it may be the only copy of that export), and (4) add/verify the R2 lifecycle rule on the supabase-backups bucket aborting incomplete multipart uploads after ~7 days. Both need a live bucket/laptop session; no Drewry decision is required. Close this issue when those two verifications are recorded here.

  10. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Issue census — 2026-11-29

    Gaps found: none material.
    Strengths: precise finding with hard evidence (6 orphaned multipart uploads initiated 2026-10-26 to 2026-10-30, part sizes, the stranded staging object and its sha256 noted); ## Acceptance criteria section present; label set complete and sane (kind/bug, priority/normal, status/ready, effort/s, area/infra, source/creator). Routing is recorded on the issue: the 2026-11-27 decision routes the backup writer work to dezren39/hatch-personal, where the writer lives.
    Actions: Verified complete — no changes needed.

  11. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Claimed by felix lane 0640-BH (worker felix), 2026-11-29. Takeover note: the only prior claims on record are 2026-11-04/09 handoffs of triage task 8279 by repo-worker-code lanes; the issue has since been re-censused three times today as status/ready with no active worker, so those claims are stale and this lane takes the item.

    Scope for this lane: the supabase_backup.py code slice — abort the multipart upload on every failure/interruption path, and finalize (hash-name + manifest) or remove the staging object on success, with tests. The stranded-object reconciliation and the R2 lifecycle backstop need live bucket access; their status will be recorded here after the code slice lands.

  12. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Premise verdict — felix lane 0640-BH (2026-11-29): the named writer no longer exists; the code acceptances are moot, the two bucket acceptances remain and are supervised work.

    Checked firsthand today, in four places:

    1. developing-today/code — no supabase_backup.py anywhere in the tree (only doc mentions: the 2026-11-18 recovery record and the 2026-11-11 design register).
    2. dezren39/hatch-personal — the design register's recorded home, workspace/supabase/muse-dev/backup/, contains only config.json on origin/main, and the commits API for supabase_backup.py at that path returns no history: the script is not in the repo.
    3. The laptop (amd-6) — filesystem search finds no supabase_backup* file and no ~/workspace/supabase/ tree; no user timer runs a Supabase backup (live timers: github-backup, atlas, openclaw, dashboard, fleet-queue D1 export). Turso shell-history files from 2026-11-17/18 corroborate the retirement during the Supabase→Turso migration.
    4. Current bucket writers — supabase-backups is alive and load-bearing, but today's writers are restic/rclone jobs under their own prefixes (restic-laptop-state, restic-sandbox-config, restic-sandbox-home, atlas, openclaw). Nothing writes pg/muse-dev/staging/ and no current writer is the Python multipart stager from the finding.

    Consequences per acceptance criterion:

    • Abort-on-failure in supabase_backup.py and finalize-or-remove the staging object on success: moot — there is no live writer to patch and the staging prefix has no writer to leak from. The leak cannot recur from this source.
    • Stranded object f4b085ed-… (sha256 5d38249d…) reconciliation: still open, not done here. It needs a live bucket read (does the object still exist under pg/muse-dev/staging/, and does its hash appear in any current manifest) followed by a supervised disposition — it may be an only copy, so no lane should move or delete it on its own.
    • R2 lifecycle backstop (abort incomplete multipart uploads after ~7 days): still open, not done here. The bucket now carries the seat's and laptop's restic backups, so a lifecycle-rule change is a live production-storage operation for a supervised pass, not a lane edit.

    Priority validation 2026-11-29 (Felix): priority/normal confirmed — with the writer retired there is no active leak; the residue is one possibly-stranded object plus a missing backstop rule on a production bucket. This lane leaves the issue open for the supervised bucket pass and releases its claim.

  13. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    state: claimed
    lane: felix 0640-BL (worker felix)
    Found via: live open-pool scan (fleet agent next is down in the #16762 flap; claim rests on this comment)

    Taking #3860: in supabase_backup.py, abort the multipart upload on every failure/interruption path, and reconcile staging on success (finalize or remove the staging object). The stranded-object reconciliation (f4b085ed, sha256 5d38249d...) and the bucket lifecycle rule are laptop/operator-side state; I will record their status rather than touch live bucket state from this lane.

  14. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    state: released — premise outdated (triage verdict)
    lane: felix 0640-BL (worker felix)

    Triage verdict (firsthand, 2026-11-29): the code-fix half of this issue has no living target.

    • supabase_backup.py does not exist in developing-today/code (full-tree grep at origin/main ddbc0ca: no file, and no Python file in the repo calls any multipart API) nor in dezren39/darwin-nix (tree scan: no supabase paths).
    • On amd-6: no supabase_backup.py under ~ (find, maxdepth 4), no supabase-backup.service unit and no timer (systemctl / list-timers).
    • Consistent with the record: the Supabase estate was recovered/migrated to Turso on 2026-11-18 (doc/2026-11-18_supabase-turso-recovery.md) and the fleet queue has since moved to the D1/Turso plane (CF-2), with infra/turso-mesh-backup as the current backup route. The writer that leaked multipart uploads is retired.

    What remains live from the original ask — both are operator-side bucket state, not lane code work:

    1. The stranded staging object pg/muse-dev/staging/f4b085ed-….api.jsonl.zst (sha256 5d38249dd92d15b07beb039e4933125a1cee00b50bd4a1b0167e670555c154e1) — reconcile or rule it a dead export. (Not touched from this lane: live bucket state.)
    2. The bucket-level backstop: an R2 lifecycle rule on supabase-backups aborting incomplete multipart uploads after ~7 days — still a sound rule for any future writer.

    Recommendation: close as superseded for the script fix; keep the two bucket items only if the bucket is still in service, as an operator task. Claim released.

  15. dezren39 commented on Nov 30, 2026

    @dezren39
    MemberAuthor

    Claim — Xaltha lane 0212-AH (2026-11-30). Taking the code slice of #3860: supabase_backup.py aborts its multipart upload on every failure/interruption path and finalizes-or-removes the staging object on success, with tests. Premise check: issue + latest comments read (last activity 2026-11-04 handoffs, leases long expired; no live claim, no open PR found). The stranded-object reconciliation and the R2 lifecycle-rule acceptance items need live bucket access and will be dispositioned separately in my resolution note if they cannot be verified from here. Note: pooled fleet gh token resolution is hanging >240s fleet-wide this window; this lane is on the FLEET_GH_RAW=1 escape hatch per the seat fallback rule.

  16. dezren39 commented on Nov 30, 2026

    @dezren39
    MemberAuthor

    agent-note — lane 0212-AU (xaltha, 2026-11-30) CLAIMING the code slice of #3860: supabase_backup.py abort-multipart-on-failure + staging finalize/remove on success. The R2 lifecycle-rule backstop and the stranded-object (f4b085ed) reconciliation need live R2 access and stay as the recorded remainder. Working via worktree from the surviving code-15432 clone family (main clone is gone seat-wide).

  17. dezren39 commented on Nov 30, 2026

    @dezren39
    MemberAuthor

    agent-note resolution (code slice) — lane 0212-AU (xaltha, 2026-11-30).

    LANDED: https://github.com/dezren39/hatch-personal-drawer/pull/4 MERGED (57e146bb) — supabase_backup.py lives in hatch-personal-drawer, not in this repo. The script already aborted on producer/compressor/dedupe paths and finalized on success; the remaining leak paths are now closed: (1) interruption (SIGINT/SIGTERM) or any unexpected raise after CreateMultipart — an atexit guard aborts the still-open upload on interpreter exit; (2) a failed CompleteMultipartUpload now aborts instead of propagating uncaught; (3) a failed post-complete Copy now returns an error naming the stranded staging key for reconciliation instead of diverging silently. Verified by py_compile + full diff read.

    REMAINDER (issue stays open): the bucket-level R2 lifecycle rule aborting incomplete multipart uploads after 7 days, reconciliation of the already-stranded object f4b085ed… (sha256 5d38249d…), and the acceptance run (deliberately failed run → list incomplete uploads = 0) — all need live R2 access from the laptop seat. Wake: next laptop-seat lane with R2 credentials runs the failed-run check and the lifecycle rule, then closes.

  18. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    Contributor

    Lane 0900-AA (Xaltha seat, wave 0900) claiming #3860.

    Premise check: latest activity is the 2026-11-03 handoff (task 8279, triage) — no live claim, no PR. The defect is live per the issue: supabase_backup.py staging uploads leak incomplete multipart uploads on failure (no abort/reconcile path).

    Plan: locate the script at current main, add abort-on-failure for the in-flight multipart upload (and reconcile of stale incomplete uploads under the staging prefix if the code shape allows), verify via remote dispatch, land as a PR with Closes #3860.

  19. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    Contributor

    Lane 0900-AA stand-down / claim released (2026-11-30). My claim above (7282555959) was based on a faulty premise read (earliest comments mistaken for latest). Correct state, verified firsthand now: lane 0212-AH claimed the code slice 2026-11-30T09:10Z and lane 0212-AU landed it — dezren39/hatch-personal-drawer PR #4 MERGED (57e146bb): supabase_backup.py aborts its R2 multipart upload on interruption (atexit + SIGTERM guard) and on CompleteMultipart failure, and names a stranded staging key on Copy failure (resolution note 2026-11-30T09:46Z on this issue).

    Remainder (not mine, recorded wake stands): the R2 lifecycle-rule backstop, the stranded f4b085ed-… reconciliation, and the failed-run acceptance check — all need live R2 access; wake = R2 credentials provisioned (the #15001 R2 secret-pair step) or an operator with bucket access. No duplicate work from this lane.

  20. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    Contributor

    Claim — lane 0900-AQ (xaltha, wave 0900 general draw), 2026-11-30.

    Taking the writer slice routed here by the 2026-11-27 decision: in dezren39/hatch-personal laptop/tools/supabase-backup/supabase_backup.py — abort the multipart upload on every failure/interruption path, and finalize-or-remove the staging object on success so pg/muse-dev/staging/ is empty between runs. The R2 lifecycle-rule backstop and the stranded-object (f4b085ed-…) reconciliation need live bucket access and stay open on this issue as the remainder.

    Key: 0900-AQ

  21. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    Contributor

    Claim released + status evidence — lane 0900-AQ (xaltha), 2026-11-30. My claim above was posted before I read the writer's current state; the premise has already been discharged in dezren39/hatch-personal. Firsthand verification this lane (file read on current hatch-personal main + commit history via the API):

    • Writer abort slice LANDED: commit e11a24ea8 (2026-11-29T08:28Z) "fix(supabase-backup): abort the staged multipart upload on every pre-finalize escape (supabase backups: staging uploads leak incomplete multipart uploads; staging never reconciled #3860)" — stage_upload() guard in laptop/tools/supabase-backup/supabase_backup.py: every pre-finalize escape (compressor spawn failure, dedupe head() failure, KeyboardInterrupt, handled failures) aborts the multipart upload best-effort before propagating; test_upload_abort.py (7 FakeS3-oracle tests) + existing suites pass per the commit record.
    • Finalize + reconcile slice LANDED: commit 147f42936 (2026-11-27T14:37Z) "supabase_backup: crash-safe finalization + stranded-staging reconcile (supabase backups: staging uploads leak incomplete multipart uploads; staging never reconciled #3860 slice 1)" — copy → manifest write → staging delete ordering, staging deleted only after verified manifest entry + final copy exist; reconcile_staging_object + --reconcile-staging flag hash-check a stranded staging key against manifest + finals and land it before removing staging; test_finalize.py (8 new tests).

    What remains open on this issue (all live-bucket work, none of it code):

    1. Criterion 1's live leg: a deliberately failed real run followed by listing incomplete multipart uploads in supabase-backups = 0.
    2. Whether --reconcile-staging has actually been run against the live stranded object f4b085ed-… (sha256 5d38249dd92d15b07beb039e4933125a1cee00b50bd4a1b0167e670555c154e1) — the code path exists; no run record found on this issue.
    3. The bucket-level backstop: R2 lifecycle rule on supabase-backups aborting incomplete multipart uploads after ~7 days, verified in bucket configuration.

    Wake: a seat/lane with live R2 access to the supabase-backups bucket runs (1) and (2), applies/verifies (3), and closes this issue with the listings as evidence. No code work remains for a code lane.

    Key: 0900-AQ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/infraeffort/sepic/storagekind/bugmeta/enrichedpriority/normalsource/creatorstatus/ready

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions