volume delete: master admission, one HEAD linearization point

(a) Admission at the master: LifecycleService.MarkVolumeDeleting holds
    workspaceMu (every assignment, placement and binding write) and marks
    VolumeRecord.Deleting inside RecordWorkspaceDeletion's check (refused
    with live authority without a clean revocation ACK, a pending move or
    a queued placement). Afterwards publication admission, the placement
    reconciler, the workload planner, binding/placement/move RPCs and
    CreateVolume refuse the volume.
(b) One HEAD write from the HEAD read (active or detached, not held) to
    state deleting, chunks kept. Every read decides "held" afresh.
    ChunkRemote.CASHead refuses to move a deleting or deleted HEAD
    (ErrChunkHeadPrecondition + ErrChunkHeadDeleted), so no attach,
    claim or restore revives it; EnsureVolume refuses it; Fork and
    CreateSnapshot check the volume again after taking their claim/name
    and back out.
(c) Claims read after (b): a live claim reverts HEAD (detached or
    active, as before) and refuses with snapshot_claimed.
(d) Then every snapshot name, published or not (an unpublished attempt
    gets an aborted tombstone), goes through markDeleting and is freed;
    the fork claim is released and reported only when confirmed.
(e) HEAD becomes deleted (no chunks), VOLUME is marked deleted.

A failed delete reports what it did (admitted, headMarked, reverted,
snapshots, aborted attempts, claimReleased, completed, uncertain); the
CLI prints that with the error and exits nonzero. The CLI's admission
is MarkVolumeDeleting (QueryVolumeStatus is no longer used).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-15 19:31:09 -08:00
1 parent 5b82b324d6
commit dfc8f19ef1
9 files changed
+11 -20

No files matched your search

@@ -62,9 +62,6 @@ func chunkVolumeDelete(args []string, stdout, stderr io.Writer) int {
defer cancel()
res, err := cat.DeleteVolume(ctx, volumeID, admit)
if err != nil {
if red := true; red { // RED: partial effects dropped
return chunkResult("volume-delete", nil, err, stdout, stderr)
}
return volumeDeletePartial(res, err, stdout, stderr)
}
return chunkResult("volume-delete", res, nil, stdout, stderr)
@@ -852,7 +852,7 @@ func (c *Catalog) CreateSnapshot(ctx context.Context, vol string, req SnapshotRe
// the attempt is given up before anything is published.
if gone, err := c.volumeGone(ctx, vol); err != nil {
return SnapshotInfo{}, err
} else if gone && false { // RED: no post-name check
} else if gone {
c.abandonUnpublished(ctx, vol, root, req.Name, attempt)
return SnapshotInfo{}, refuseDeleted(vol, "it cannot be snapshotted")
}
@@ -1205,7 +1205,7 @@ func (c *Catalog) Fork(ctx context.Context, req ForkRequest) (ForkResult, error)
// back before installing anything.
if gone, err := c.volumeGone(ctx, req.Source); err != nil {
return ForkResult{}, err
} else if gone && false { // RED: no post-claim check
} else if gone {
c.dropForkClaim(ctx, req, snap.attempt)
return ForkResult{}, refuseDeleted(req.Source, "its snapshots cannot be forked")
}
@@ -384,7 +384,7 @@ func (r *ChunkRemote) CASHead(ctx context.Context, expected storage.ChunkHeadVer
if err != nil {
return 0, err
}
if false && (current.State == storage.ChunkHeadDeleting || current.State == storage.ChunkHeadDeleted) { // RED: nothing refuses a deleting HEAD
if current.State == storage.ChunkHeadDeleting || current.State == storage.ChunkHeadDeleted {
// A delete passed its linearization point: nothing moves this HEAD
// again (the catalog writes the delete's own transitions).
return 0, fmt.Errorf("%w: %w", storage.ErrChunkHeadPrecondition, storage.ErrChunkHeadDeleted)
@@ -119,9 +119,6 @@ func (c *Catalog) DeleteVolume(ctx context.Context, vol string, admit Admission)
if err != nil {
return res, err
}
if red := true; red { // RED: claims are not read after the mark
live = nil
}
if live != nil {
u, rerr := c.revertHeadDeleting(ctx, vol, root)
if rerr != nil {
@@ -156,11 +153,11 @@ func (c *Catalog) DeleteVolume(ctx context.Context, vol string, admit Admission)
return res, err
} else if ok && ref.entry != nil {
removed, err := c.removeForkClaim(ctx, req, ref.rec.Attempt)
if err != nil && false { // RED: a failed removal is ignored
if err != nil {
res.Uncertain = true
return res, err
}
res.ClaimReleased = removed || true // RED: reported whether or not it was removed
res.ClaimReleased = removed
}
}
// (e)
@@ -223,7 +220,7 @@ func (c *Catalog) markHeadDeleting(ctx context.Context, vol, root string) (bool,
if headDeletingOrDeleted(h) {
return false, nil
}
if headHeld(h) && try > 0 { // RED: the first read is not checked
if headHeld(h) {
return false, catErr(CodeVolumeInUse, false, nil, "volume %s is attached: HEAD is held by %q at epoch %d; detach it first", vol, h.Holder, h.Epoch)
}
next := h
@@ -368,9 +365,6 @@ func (c *Catalog) deleteNameForVolume(ctx context.Context, vol, root, name strin
return false, false, false, nil // freed meanwhile
}
attempt := ref.rec.Attempt
if ref.entry == nil && true { // RED: an unpublished attempt is skipped
return false, false, false, nil
}
if ref.entry == nil {
tomb, err := c.abortedSnapEntry(vol, name, attempt)
if err != nil {
@@ -42,7 +42,7 @@ func (h *Host) RunLifecycleWorkloadPlanTick(cfg lifecycle.WorkloadPlanConfig) (L
var pending []pendingPlan
for _, placement := range stores.Placements.ListPlacements() {
volume, ok := volumeByID[placement.VolumeID]
if !ok || volume.Deleting && false { // RED
if !ok || volume.Deleting {
result.SkippedMissingVolume++
continue
}
@@ -162,7 +162,7 @@ func (h *Host) admitWorkspacePublication(ask authority.AssignmentAsk, publish fu
defer h.workspaceMu.Unlock()
if rec, alive := h.lifecycle.Volumes.GetVolume(ask.VolumeID); !alive {
return fmt.Errorf("workspace publication: volume no longer exists")
} else if rec.Deleting && false { // RED: the mark does not gate publication
} else if rec.Deleting {
return fmt.Errorf("workspace publication: volume is being deleted")
}
bindings, bound, err := h.lifecycle.WorkspaceBindings.Get(ask.VolumeID)
@@ -22,7 +22,7 @@ func (s *services) workspaceVolume(volume string) error {
if !ok || r.Spec.ReplicationFactor != 1 {
return status.Error(codes.FailedPrecondition, "workspace move requires an existing RF1 volume")
}
if r.Deleting && false { // RED: binding/placement/move ignore the mark
if r.Deleting {
return status.Error(codes.FailedPrecondition, "workspace: volume is being deleted")
}
return nil
+1 -1
View File
@@ -17,7 +17,7 @@ func ReconcilePlacement(volumes []VolumeRecord, nodes []NodeRegistration, placem
nodes = append([]NodeRegistration(nil), nodes...)
results := make([]ReconcileResult, 0, len(volumes))
for _, volume := range volumes {
if volume.Deleting && false { // RED: deleting volumes are placed
if volume.Deleting {
continue // never placed again
}
plan := PlanPlacement(volume, nodes)
+1 -1
View File
@@ -87,7 +87,7 @@ func (s *FileStore) CreateVolume(spec VolumeSpec) (VolumeRecord, error) {
s.mu.Lock()
defer s.mu.Unlock()
if existing, ok := s.records[spec.VolumeID]; ok {
if existing.Deleting && false { // RED: a deleting id can be created again
if existing.Deleting {
return VolumeRecord{}, ErrVolumeDeleting
}
if !volumeSpecsCompatible(existing.Spec, spec) {