feat: add atomic file writer with SemaphoreSlim for crash-safe state writes (Gap 1.6)
- Add AtomicFileWriter static helper: writes to {path}.{random}.tmp, flushes,
then File.Move(overwrite:true) — concurrent-safe via unique temp path per call
- Add _stateWriteLock (SemaphoreSlim 1,1) to FileStore; dispose in both Dispose
and DisposeAsync paths
- Promote WriteStreamState to async WriteStreamStateAsync using AtomicFileWriter
under the write lock; FlushAllPending now returns Task
- Update IStreamStore.FlushAllPending signature to Task; fix MemStore no-op impl
- Fix FileStoreCrashRecoveryTests to await FlushAllPending (3 sync→async tests)
- Add 9 AtomicFileWriterTests covering create, no-tmp-remains, overwrite,
concurrent safety, memory overload, empty data, and large payload
This commit is contained in:
@@ -56,7 +56,7 @@ public interface IStreamStore
|
||||
=> throw new NotSupportedException("Block-engine SkipMsgs not yet implemented.");
|
||||
|
||||
// Go: StreamStore.FlushAllPending — flush any buffered writes to backing storage
|
||||
void FlushAllPending()
|
||||
Task FlushAllPending()
|
||||
=> throw new NotSupportedException("Block-engine FlushAllPending not yet implemented.");
|
||||
|
||||
// Go: StreamStore.LoadMsg — load message by exact sequence; sm is an optional reusable buffer
|
||||
|
||||
Reference in New Issue
Block a user