Skip to content

[P2] Partial GCS/S3 upload on checkpoint leaves orphaned objects — bucket grows without bound #610

Open

Description

Severity: P2 (silent storage cost growth; orphans are permanent)
Component: Node Layer — cmd/atelet/main.go
Audit ID: NL-7


Summary

uploadExternalCheckpoint launches one goroutine per snapshot file. If any goroutine
fails, already-uploaded files are not cleaned up — they remain as orphaned objects
in the bucket. Similarly, if the manifest upload fails after all data files upload
successfully, the snapshot data is in the bucket with no manifest. No DeleteObject
call exists anywhere in the codebase. Over time, partial failed checkpoints accumulate
as unreferenced objects consuming storage.


Root Cause

File: cmd/atelet/main.go lines 458–488

g, gCtx := errgroup.WithContext(ctx)
for _, file := range snapshotFiles {
    file := file
    g.Go(func() error {
        return SendLocalFileToGCSWithZstd(gCtx, client, bucket, file)
        // If this goroutine SUCCEEDS, objects are in GCS
    })
}
if err := g.Wait(); err != nil {
    // One goroutine failed — but successful goroutines already wrote objects
    // No cleanup of the already-uploaded objects
    return err
}
// Upload manifest
if err := writeManifest(ctx, client, bucket, manifest); err != nil {
    // Data files are in GCS, manifest is not — orphaned data
    return err
}

grep -rn "DeleteObject\|DeleteObjects\|Objects().Delete" /Users/adityashantanu/repos/substrate/ — zero results.


Steps to Reproduce

  1. Configure GCS to accept data file PUTs but reject the manifest PUT (e.g., via
    a custom object name ACL or a test proxy that drops requests for manifest.json).
  2. Trigger a checkpoint:
    kubectl ate suspend actor my-actor -a demo
  3. Observe: SuspendActor returns an error; actor is CRASHED (per ISSUE-002).
  4. List GCS objects for the actor:
    gcloud storage ls -r gs://<BUCKET>/<atespace>/<actor-uid>/
    # Shows: memory-ranges.zstd, disk.zstd, ... (all data files)
    # Missing: manifest.json
  5. These objects remain in the bucket permanently:
    # After deleting the actor
    kubectl ate delete actor my-actor -a demo
    gcloud storage ls -r gs://<BUCKET>/<atespace>/<actor-uid>/
    # Still shows the orphaned data files

Expected Behavior

On partial upload failure, atelet should attempt to delete already-uploaded objects
(best-effort). If the cleanup also fails, the objects should be reported to a "orphan
cleanup" registry or the bucket should have an object lifecycle policy to auto-expire
objects without a companion manifest.json after 24 hours.


Suggested Fix

Short-term: Add a best-effort cleanup in uploadExternalCheckpoint on failure:

if err := g.Wait(); err != nil {
    // Best-effort cleanup
    for _, uploaded := range successfullyUploaded {
        _ = client.DeleteObject(ctx, bucket, uploaded)
    }
    return err
}

Long-term: Configure GCS lifecycle rules on the snapshot bucket:

{
  "rule": [{
    "condition": {"age": 2, "matchesSuffix": [".zstd"]},
    "action": {"type": "Delete"}
  }]
}

This provides a safety net for any orphaned partial uploads.

Also add a periodic bucket audit that finds objects without a companion manifest.json
in the same prefix and deletes them (or alerts on them).

Activity

  1. added
    prio/P2
    kind/bug
    on Jul 30, 2026
  2. changed the title [-]Partial GCS/S3 upload on checkpoint leaves orphaned objects — bucket grows without bound[/-] [+][P2] Partial GCS/S3 upload on checkpoint leaves orphaned objects — bucket grows without bound[/+] on Jul 30, 2026
  3. yjjnls commented on Nov 18, 2026

    @yjjnls

    Adding a viewpoint from the operations side — we run a large fleet of checkpoint/snapshot-backed sandboxes and spend a nontrivial amount of time on exactly this failure class: partial uploads, failed manifests, and the unreferenced objects they leave behind. So this issue reads very familiar.

    Two thoughts on shape, for whatever they are worth beyond the issue's own suggestion:

    1. Best-effort rollback of already-uploaded objects on failure is the right first step, but it cannot be the whole story, because the cleanup itself can fail — that is how orphans are born in the first place. What has made the difference for us is pairing the failure-path cleanup with a cheap reconciliation loop: per-prefix listing vs. the manifest-backed reference set, where "objects with no companion manifest" is itself the alert signal, plus an object-lifecycle expiry rule as the safety net for whatever reconciliation misses.
    2. From the history here, Limit memory used by concurrent snapshot uploads #2708 bounded the memory of concurrent snapshot uploads in this same path without adding failure cleanup, so the orphan half has stayed open. Happy to take that half end to end (failure-path cleanup + reconciliation check) if that is welcome.

    Eitan Yarmush (@EItanya) — is there a plan for the orphan half already, or is it open? Interested in taking this on unless you already have something in progress — happy to coordinate.

  4. EItanya commented on Nov 20, 2026

    @EItanya
    Collaborator

    Status at 57f360a.

    Fixed:

    Still open:

    • atelet does not clean up when an upload fails. uploadSnapshot in cmd/atelet/main.go returns the error and leaves the files already uploaded.
    • On a live actor those objects stay until the actor is deleted or reverted. releaseDroppedSnapshots releases only COMPLETED snapshots, and pruneSnapshots drops an earlier PENDING record at the next suspend, so after that only DeleteActor removes them.
    • Nothing lists a bucket for objects that have no manifest, and this repo sets no bucket lifecycle rule.

    This status was generated and checked by Claude. Eitan did his best to verify it, but there are a lot of open issues, so please correct anything that is wrong.

    Comment left by Claude on behalf of Eitan Yarmush (@EItanya).

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

Metadata

Metadata

Labels

area/storagekind/bugprio/P2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions