Skip to content

Commit 15849a8

Browse files
committed
fsync while writting last tombstone in purge
1 parent 4a7566f commit 15849a8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

server/filestore.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9044,6 +9044,13 @@ func (fs *fileStore) purge(fseq uint64) (uint64, error) {
90449044
// Leave a tombstone so we can remember our starting sequence in case
90459045
// full state becomes corrupted.
90469046
fs.writeTombstone(lseq, lmb.last.ts)
9047+
if lmb.mfd != nil {
9048+
// Sync is critical here: after purge, the message block may be 0 bytes (especially for workqueue streams), and
9049+
// the index may also be 0 bytes. The tombstone will be the only persistent record of the last sequence number.
9050+
// We must ensure it's durably written to disk before returning; otherwise, a crash could leave the
9051+
// stream in an unrecoverable state with no sequence history.
9052+
lmb.mfd.Sync()
9053+
}
90479054
}
90489055

90499056
cb := fs.scb

0 commit comments

Comments
 (0)