diff options
| author | historia <[not public]> | 2026-09-18 16:13:49 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 16:13:49 -0400 |
| commit | 194164a77eb4f2479b94c19e6f0e1278ab608781 (patch) | |
| tree | 53413add8ed6f32a34d1733397e380cc98ef70ef /internal/persistence/txn.go | |
| parent | 67e01aab85607b9e601185c7d62dff576af3bb43 (diff) | |
| download | thehouseoficarus-194164a77eb4f2479b94c19e6f0e1278ab608781.tar.gz | |
fix: more casino, economy, gameplay, security, and world data hardening gaps
Diffstat (limited to 'internal/persistence/txn.go')
| -rw-r--r-- | internal/persistence/txn.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/persistence/txn.go b/internal/persistence/txn.go index d09feaa..8ba21fa 100644 --- a/internal/persistence/txn.go +++ b/internal/persistence/txn.go @@ -238,6 +238,15 @@ func (t *Transaction) Commit() error { } journalPath := filepath.Join(t.journalDir, "txn-"+hex.EncodeToString(id[:])+".json") if err := WriteFile(journalPath, journal, 0600); err != nil { + // WriteFile can fail AFTER the rename (e.g. the directory fsync), + // leaving a complete, valid journal whose operations were never + // applied. Remove it before returning so a later Recover cannot replay + // its before-images over newer writes; if the removal also fails, + // surface that so the caller can stop admitting mutations instead of + // serving on with an unrecoverable journal on disk. + if rErr := t.removeJournalDurable(journalPath); rErr != nil { + return fmt.Errorf("write journal: %v; journal cleanup failed (journal left on disk): %v", err, rErr) + } return fmt.Errorf("write journal: %w", err) } |
