Survive a power loss right after a snapshot or switch: flush git writes and repair a damaged index #163

Closed
opened 2026-10-25 23:36:46 -05:00 by ethan-hann · 1 comment
Owner

Found by a resilience review (report kept by the maintainer). RepoConfigFile.cs:104-119 sets no core.fsync, so the index, refs and loose objects (saves are small files, stored loose) are not flushed. With bundled git 2.56.0.windows.2, an emptied index makes every command fail with "index file smaller than expected" (exit 128), and SavePoint has no repair path; every snapshot, switch and discard for that game then fails. Fix: add core.fsync=committed,index and core.fsyncMethod=batch to the managed config and bump the config stamp (as D47/D50 did), measuring the capture-time cost on a mid-range PC; map index-damage errors to a typed error and repair with read-tree HEAD under the game lock (changes no game file).

Found by a resilience review (report kept by the maintainer). RepoConfigFile.cs:104-119 sets no core.fsync, so the index, refs and loose objects (saves are small files, stored loose) are not flushed. With bundled git 2.56.0.windows.2, an emptied index makes every command fail with "index file smaller than expected" (exit 128), and SavePoint has no repair path; every snapshot, switch and discard for that game then fails. Fix: add core.fsync=committed,index and core.fsyncMethod=batch to the managed config and bump the config stamp (as D47/D50 did), measuring the capture-time cost on a mid-range PC; map index-damage errors to a typed error and repair with read-tree HEAD under the game lock (changes no game file).
ethan-hann added this to the 1.0 milestone 2026-10-25 23:36:46 -05:00
Author
Owner

Shipped in 0.9.15 (pull request 174).

Shipped in 0.9.15 (pull request 174).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ethan-hann/SavePoint#163
No description provided.