Skip to content

Commit

Permalink
[IMPROVED] Recycle buffers on rebuild and write out our full state pr…
Browse files Browse the repository at this point in the history
…ior to snapshotting (#4699)

Signed-off-by: Derek Collison <[email protected]>
  • Loading branch information
derekcollison authored Oct 25, 2023
2 parents 13f6e63 + 2a9be3c commit 8b734aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,8 @@ func (mb *msgBlock) rebuildStateLocked() (*LostStreamData, []uint64, error) {
mb.clearCacheAndOffset()

buf, err := mb.loadBlock(nil)
defer recycleMsgBlockBuf(buf)

if err != nil || len(buf) == 0 {
var ld *LostStreamData
// No data to rebuild from here.
Expand Down Expand Up @@ -7350,6 +7352,9 @@ func (fs *fileStore) Snapshot(deadline time.Duration, checkMsgs, includeConsumer
}
}

// Write out full state as well before proceeding.
fs.writeFullState()

pr, pw := net.Pipe()

// Set a write deadline here to protect ourselves.
Expand Down

0 comments on commit 8b734aa

Please sign in to comment.