diff options
| author | historia <[not public]> | 2026-09-16 13:52:58 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-16 13:52:58 -0400 |
| commit | c054b27f628f23fecc505b9e09e78721738f3c4e (patch) | |
| tree | ea197165bc454ee811dd22b9ceef5dc94bb0b279 /internal/persistence/txn_test.go | |
| parent | f2d44f10f52d3fe68fdb19b518a330f7af9e1ed2 (diff) | |
| download | thehouseoficarus-c054b27f628f23fecc505b9e09e78721738f3c4e.tar.gz | |
fix: shutdown admission, recovery identity/order, rollback journal retention, pickup merge
Diffstat (limited to 'internal/persistence/txn_test.go')
| -rw-r--r-- | internal/persistence/txn_test.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/internal/persistence/txn_test.go b/internal/persistence/txn_test.go index 10a809d..796cd56 100644 --- a/internal/persistence/txn_test.go +++ b/internal/persistence/txn_test.go @@ -99,8 +99,31 @@ func TestTxnRollbackOnFailure(t *testing.T) { if got := readTestFile(t, filepath.Join(sub, "gone.yaml")); got != "old-gone" { t.Fatalf("rollback did not restore deleted file: %q", got) } + // The restore of gone.yaml ran inside the still read-only directory, so + // the ROLLBACK itself failed there: the journal is the only durable + // record of the pre-transaction state and must be KEPT (deleting it + // would make any remaining divergence unrecoverable). See + // TestCommitKeepsJournalAfterFailedRollback. + if entries, _ := ListJournalFiles(journalDir); len(entries) != 1 { + t.Fatalf("journal must be kept after a failed rollback: %v", entries) + } + + // Repair the directory permission: the next Recover completes the + // rollback and cleans the journal. + if err := os.Chmod(sub, 0700); err != nil { + t.Fatal(err) + } + if err := Recover(journalDir); err != nil { + t.Fatalf("recovery retry after repair: %v", err) + } + if got := readTestFile(t, filepath.Join(dir, "a.yaml")); got != "old-a" { + t.Fatalf("recovery retry disturbed a.yaml: %q", got) + } + if got := readTestFile(t, filepath.Join(sub, "gone.yaml")); got != "old-gone" { + t.Fatalf("recovery retry disturbed gone.yaml: %q", got) + } if entries, _ := ListJournalFiles(journalDir); len(entries) != 0 { - t.Fatalf("journal not cleaned after rollback: %v", entries) + t.Fatalf("completed recovery left journals behind: %v", entries) } } |
