mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Revert closeAndKeepIndex behavior
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -5541,40 +5541,21 @@ func (fs *fileStore) removeMsgBlock(mb *msgBlock) {
|
||||
// When we have an empty block but want to keep the index for timestamp info etc.
|
||||
// Lock should be held.
|
||||
func (mb *msgBlock) closeAndKeepIndex(viaLimits bool) {
|
||||
// We will leave a 0 length blk marker so we can remember.
|
||||
doIO := func() {
|
||||
// Write out empty file.
|
||||
os.WriteFile(mb.mfn, nil, defaultFilePerms)
|
||||
// Make sure to write the index file so we can remember last seq and ts.
|
||||
mb.writeIndexInfoLocked()
|
||||
mb.removePerSubjectInfoLocked()
|
||||
if mb.ifd != nil {
|
||||
mb.ifd.Close()
|
||||
mb.ifd = nil
|
||||
}
|
||||
}
|
||||
|
||||
// We will leave a 0 length blk marker.
|
||||
if mb.mfd != nil {
|
||||
mb.mfd.Close()
|
||||
mb.mfd = nil
|
||||
// We used to truncate here but can be quite expensive based on platform.
|
||||
mb.mfd.Truncate(0)
|
||||
} else {
|
||||
// We were closed, so just write out an empty file.
|
||||
os.WriteFile(mb.mfn, nil, defaultFilePerms)
|
||||
}
|
||||
// Make sure to write the index file so we can remember last seq and ts.
|
||||
mb.writeIndexInfoLocked()
|
||||
// Close
|
||||
mb.dirtyCloseWithRemove(false)
|
||||
|
||||
// Make sure to remove fss state.
|
||||
mb.fss = nil
|
||||
|
||||
// If via limits we can do this out of line in separate Go routine.
|
||||
if viaLimits {
|
||||
go func() {
|
||||
mb.mu.Lock()
|
||||
defer mb.mu.Unlock()
|
||||
doIO()
|
||||
}()
|
||||
} else {
|
||||
doIO()
|
||||
}
|
||||
mb.removePerSubjectInfoLocked()
|
||||
|
||||
// If we are encrypted we should reset our bek counter.
|
||||
if mb.bek != nil {
|
||||
|
||||
Reference in New Issue
Block a user