fix(cleanup): retry receipt directory durability before deletion

This commit is contained in:
2026-10-11 21:12:08 +08:00
parent 1068188e71
commit 2fd883aec5
@@ -93,6 +93,10 @@ func (r *RecordingRecovery) preserveCleanupProof(entry RecordingRecoveryEntry) (
if err := privateCleanupDirectory(dir); err != nil {
return "", err
}
// A prior attempt may have created the namespace but failed its sync.
if err := syncDirectory(r.Root); err != nil {
return "", err
}
before, err := r.readCleanupProof(path)
if err == nil {
original, marshalErr := json.Marshal(entry)
@@ -103,6 +107,11 @@ func (r *RecordingRecovery) preserveCleanupProof(entry RecordingRecoveryEntry) (
if !bytes.Equal(original, persisted) {
return "", errors.New("recording cleanup proof conflicts with current recording")
}
// Also retry a previously failed rename-directory sync before unlinking
// originals; seeing the receipt in this process is not durability proof.
if err := syncDirectory(dir); err != nil {
return "", err
}
return path, nil
}
if !errors.Is(err, os.ErrNotExist) {