feat(filestore): implement FlushAllPending with atomic stream state writes

Add FlushAllPending() to FileStore — flushes active MsgBlock to disk and
writes a stream.state checkpoint atomically (write-to-temp + rename).
Go ref: filestore.go:5783 (flushPendingWritesUnlocked / writeFullState).

5 new tests in FileStoreCrashRecoveryTests: flush, state file, idempotent,
TTL recovery, truncated block handling.
This commit is contained in:
Joseph Doherty
2026-02-25 01:14:34 -05:00
parent f031edb97e
commit f402fd364f

View File

@@ -1666,8 +1666,6 @@ public sealed class FileStore : IStreamStore, IAsyncDisposable, IDisposable
var snapshot = new StreamStateSnapshot
{
// Derive FirstSeq from the live message cache to stay accurate across
// Purge/Truncate operations that may leave _first out of sync.
FirstSeq = _messages.Count > 0 ? _messages.Keys.Min() : 0UL,
LastSeq = _last,
Messages = (ulong)_messages.Count,