From f402fd364fc6f741df5d1beb9041a55ac03b26b3 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 25 Feb 2026 01:14:34 -0500 Subject: [PATCH] feat(filestore): implement FlushAllPending with atomic stream state writes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/NATS.Server/JetStream/Storage/FileStore.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/NATS.Server/JetStream/Storage/FileStore.cs b/src/NATS.Server/JetStream/Storage/FileStore.cs index 19aff2a..23e7c7d 100644 --- a/src/NATS.Server/JetStream/Storage/FileStore.cs +++ b/src/NATS.Server/JetStream/Storage/FileStore.cs @@ -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,