mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
volume delete: durable master reservation, commit point, settled abort
- Master: a deletion reservation store (core/lifecycle), separate from the desired-volume records, so an unknown id is reserved too and the ordinary DeleteVolume/CreateVolume path cannot clear it. Held by per-delete tokens (admitted), permanent once committed. Writes reuse the binding store's crash-safe pattern (synced temp file, atomic rename, synced directory); an unknown outcome keeps a protective change in memory (fail closed). MarkVolumeDeleting records it under RecordWorkspaceDeletion's check; new AbortVolumeDeleting and CommitVolumeDeleting. Every gate (publication admission, reconciler, workload planner, binding/placement/move, CreateVolume) consults it. VolumeRecord.Deleting is gone. - Catalog: Admission is Admit/Commit/Abort; ErrNotAdmitted marks a definite refusal, anything else is an unknown outcome (admissionUncertain). Every give-back aborts this delete's admission. A commit point (HEAD deleting -> purging, conditioned on the HEAD read) precedes the irreversible steps; a revert races on the same write, so a delete that sampled a claim cannot undo another delete's commit, and reports an error instead of a give-back. - CreateSnapshot's back-out settles its name like the delete does: the name is freed only after the attempt's tombstone or winning publication is confirmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
77d238ce59
commit
2e078746ee
4 files changed
+4
-17
No files matched your search
@@ -856,14 +856,7 @@ func (c *Catalog) CreateSnapshot(ctx context.Context, vol string, req SnapshotRe
|
||||
// Settle this name as the delete does: the attempt's tombstone or
|
||||
// its winning publication is confirmed before the name is freed;
|
||||
// on failure the name stays, so the delete still finds it.
|
||||
if red := true; red { // RED: the name is freed even when the abort write failed
|
||||
if tomb, err := c.abortedSnapEntry(vol, req.Name, attempt); err == nil {
|
||||
_ = c.f.CreateEntry(ctx, path.Join(root, snapsDir, req.Name), tomb, true)
|
||||
}
|
||||
_, _, _ = c.freeName(ctx, root, req.Name, attempt)
|
||||
} else {
|
||||
_, _, _, _ = c.deleteNameForVolume(ctx, vol, root, req.Name)
|
||||
}
|
||||
_, _, _, _ = c.deleteNameForVolume(ctx, vol, root, req.Name)
|
||||
return SnapshotInfo{}, refuseDeleted(vol, "it cannot be snapshotted")
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ func (c *Catalog) DeleteVolume(ctx context.Context, vol string, admit Admission)
|
||||
// commit an earlier run may have lost).
|
||||
if admit != nil {
|
||||
if err := admit.Admit(ctx, vol); err != nil {
|
||||
if errors.Is(err, ErrNotAdmitted) || true { // RED: any admission error reads as a refusal
|
||||
if errors.Is(err, ErrNotAdmitted) {
|
||||
return res, catErr(CodeVolumeInUse, false, err, "volume %s: delete not admitted", vol)
|
||||
}
|
||||
res.AdmissionUncertain, res.Uncertain = true, true
|
||||
@@ -133,9 +133,6 @@ func (c *Catalog) DeleteVolume(ctx context.Context, vol string, admit Admission)
|
||||
}
|
||||
res.Admitted = true
|
||||
giveBack := func(cause error) (VolumeDeleteResult, error) {
|
||||
if red := true; red { // RED: a give-back leaves the admission in place
|
||||
return res, cause
|
||||
}
|
||||
if admit != nil {
|
||||
if err := admit.Abort(ctx, vol); err != nil {
|
||||
res.Uncertain = true
|
||||
@@ -169,7 +166,7 @@ func (c *Catalog) DeleteVolume(ctx context.Context, vol string, admit Admission)
|
||||
case rerr != nil:
|
||||
res.Uncertain = u
|
||||
return res, rerr
|
||||
case !reverted && false: // RED: a revert that found the HEAD committed still counts as given back
|
||||
case !reverted:
|
||||
// Another delete committed meanwhile: its irreversible steps
|
||||
// stand; this call neither reverts nor gives back.
|
||||
return res, catErr(CodeOutcomeUnknown, true, nil, "volume %s: another delete committed while this one found %v; rerun the delete", vol, live)
|
||||
|
||||
@@ -60,7 +60,7 @@ func (s *services) CreateVolume(ctx context.Context, req *control.CreateVolumeRe
|
||||
// created again; the reservation is checked under the lock its writer
|
||||
// holds.
|
||||
s.host.workspaceMu.Lock()
|
||||
reserved := stores.Deletions.Reserved(spec.VolumeID) && false // RED: the reservation does not stop CreateVolume
|
||||
reserved := stores.Deletions.Reserved(spec.VolumeID)
|
||||
s.host.workspaceMu.Unlock()
|
||||
if reserved {
|
||||
return nil, status.Errorf(codes.FailedPrecondition, "create volume: %s is being deleted or was deleted; its id is never reused", spec.VolumeID)
|
||||
|
||||
@@ -189,9 +189,6 @@ func (s *DeletionReservationStore) update(vol string, protective bool, change fu
|
||||
}
|
||||
|
||||
func (s *DeletionReservationStore) persist(next map[string]DeletionReservation, protective bool) error {
|
||||
if red := true; red { // RED: intent-only, nothing written or synced
|
||||
return nil
|
||||
}
|
||||
b, err := json.Marshal(next)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user