Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions server/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7104,19 +7104,19 @@ func (mb *msgBlock) flushPendingMsgsLocked() (*LostStreamData, error) {
if ts := ats.AccessTime(); ts < mb.llts || (ts-mb.llts) <= int64(mb.cexp) {
mb.cache.wp += lob
} else {
if cap(mb.cache.buf) <= maxBufReuse {
buf = mb.cache.buf[:0]
} else {
recycleMsgBlockBuf(mb.cache.buf)
buf = nil
}
if moreBytes > 0 {
nbuf := mb.cache.buf[len(mb.cache.buf)-moreBytes:]
if moreBytes > (len(mb.cache.buf)/4*3) && cap(nbuf) <= maxBufReuse {
buf = nbuf
if moreBytes == 0 {
if cap(mb.cache.buf) <= maxBufReuse {
// Reuse the entire underlying buffer
buf = mb.cache.buf[:0]
} else {
buf = append(buf, nbuf...)
recycleMsgBlockBuf(mb.cache.buf)
buf = nil
}
} else {
// Move the additional bytes to the beginning of the buffer and re-slice so
// we will have more usable capacity at the end again for additional writes.
copy(mb.cache.buf[:moreBytes], mb.cache.buf[len(mb.cache.buf)-moreBytes:])
buf = mb.cache.buf[:moreBytes]
}
// Update our cache offset.
mb.cache.off = int(woff)
Expand Down Expand Up @@ -7262,7 +7262,7 @@ func (mb *msgBlock) loadMsgsWithLock() error {
checkCache:
nchecks++
if nchecks > 8 {
return errCorruptState
return errNoCache
}

// Check to see if we have a full cache.
Expand Down