Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVED] Additional markers for dirty state #4601

Merged
merged 1 commit into from Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions server/filestore.go
Expand Up @@ -2058,6 +2058,12 @@ func (fs *fileStore) expireMsgsOnRecover() {
// Clear any global subject state.
fs.psim = make(map[string]*psi)
}

// If we purged anything, make sure we kick flush state loop.
if purged > 0 {
fs.dirty++
fs.kickFlushStateLoop()
}
}

func copyMsgBlocks(src []*msgBlock) []*msgBlock {
Expand Down Expand Up @@ -3504,6 +3510,7 @@ func (fs *fileStore) removeMsg(seq uint64, secure, viaLimits, needFSLock bool) (
rbytes := mb.rbytes - uint64(mb.dmap.Size()*emptyRecordLen)
if rbytes>>2 > mb.bytes {
mb.compact()
fs.kickFlushStateLoop()
}
}
}
Expand Down Expand Up @@ -3655,7 +3662,7 @@ func (mb *msgBlock) compact() {
}

// Remove index file and wipe delete map, then rebuild.
mb.deleteDmap()
mb.dmap.Empty()
mb.rebuildStateLocked()

// If we entered with the msgs loaded make sure to reload them.
Expand All @@ -3664,11 +3671,6 @@ func (mb *msgBlock) compact() {
}
}

// Empty out our dmap.
func (mb *msgBlock) deleteDmap() {
mb.dmap.Empty()
}

// Grab info from a slot.
// Lock should be held.
func (mb *msgBlock) slotInfo(slot int) (uint32, uint32, bool, error) {
Expand Down Expand Up @@ -6379,6 +6381,12 @@ func (fs *fileStore) reset() error {
fs.psim = make(map[string]*psi)
fs.bim = make(map[uint32]*msgBlock)

// If we purged anything, make sure we kick flush state loop.
if purged > 0 {
fs.dirty++
fs.kickFlushStateLoop()
}

fs.mu.Unlock()

if cb != nil {
Expand Down Expand Up @@ -6502,6 +6510,7 @@ func (fs *fileStore) removeMsgBlockFromList(mb *msgBlock) {
// Remove from list.
for i, omb := range fs.blks {
if mb == omb {
fs.dirty++
blks := append(fs.blks[:i], fs.blks[i+1:]...)
fs.blks = copyMsgBlocks(blks)
if fs.bim != nil {
Expand Down