Skip to content

Commit

Permalink
Fix race condition in TestFileStoreAgeLimitRecovery
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
neilalexander committed Jul 26, 2023
1 parent 4d8d019 commit 65cb4b9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/filestore.go
Expand Up @@ -419,9 +419,13 @@ func newFileStoreWithCreated(fcfg FileStoreConfig, cfg StreamConfig, created tim
// If the stream has an initial sequence number then make sure we
// have purged up until that point. We will do this only if the
// recovered first sequence number is before our configured first
// sequence.
fs.FastState(&fs.state)
if cfg.FirstSeq > 0 && fs.state.FirstSeq <= cfg.FirstSeq {
// sequence. Need to do this locked as by now the age check timer
// has started.
var st StreamState
fs.mu.RLock()
fs.FastState(&st)
fs.mu.RUnlock()
if cfg.FirstSeq > 0 && st.FirstSeq <= cfg.FirstSeq {
if _, err := fs.purge(cfg.FirstSeq); err != nil {
return nil, err
}
Expand Down

0 comments on commit 65cb4b9

Please sign in to comment.