Skip to content

Commit

Permalink
Fix FirstSeq not being updated with filestore when purging subject (#…
Browse files Browse the repository at this point in the history
…4042)

Resolves #4041

Keeps `firstSeqNeedsUpdate` set if set previously, to ensure the
FirstSeq gets updated.
  • Loading branch information
derekcollison committed Apr 12, 2023
2 parents 2a03d9d + 1e2bba4 commit 4fcc2ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/filestore.go
Expand Up @@ -5098,7 +5098,8 @@ func (fs *fileStore) PurgeEx(subject string, sequence, keep uint64) (purged uint
if mb.isEmpty() {
fs.removeMsgBlock(mb)
i--
firstSeqNeedsUpdate = seq == fs.state.FirstSeq
// keep flag set, if set previously
firstSeqNeedsUpdate = firstSeqNeedsUpdate || seq == fs.state.FirstSeq
} else if seq == fs.state.FirstSeq {
fs.state.FirstSeq = mb.first.seq // new one.
fs.state.FirstTime = time.Unix(0, mb.first.ts).UTC()
Expand Down
1 change: 1 addition & 0 deletions server/filestore_test.go
Expand Up @@ -4020,6 +4020,7 @@ func TestFileStorePurgeExWithSubject(t *testing.T) {
require_True(t, int(p) == total)
require_True(t, int(p) == total)
require_True(t, fs.State().Msgs == 1)
require_True(t, fs.State().FirstSeq == 201)
})
}

Expand Down

0 comments on commit 4fcc2ff

Please sign in to comment.