diff --git a/internal/agent/recording_cleanup_proof.go b/internal/agent/recording_cleanup_proof.go index f63b620..dd249ec 100644 --- a/internal/agent/recording_cleanup_proof.go +++ b/internal/agent/recording_cleanup_proof.go @@ -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) {