Skip to content

Commit

Permalink
Fix eviction of FLUSHED_FULL buffers
Browse files Browse the repository at this point in the history
They were erroneously deleted instead of being turned into FL_CLEARED
  • Loading branch information
vitalif committed Dec 20, 2023
1 parent fc48aca commit 609c7b9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion internal/buffer_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (l *BufferList) EvictFromMemory(buf *FileBuffer) (allocated int64, deleted
l.queue(buf)
deleted = true
}
} else if buf.dirtyID == 0 {
} else if buf.state == BUF_CLEAN {
l.unqueue(buf)
l.at.Delete(buf.offset+buf.length)
deleted = true
Expand Down Expand Up @@ -634,6 +634,24 @@ func (l *BufferList) split(b *FileBuffer, offset uint64) (left, right *FileBuffe
return &startBuf, b
}

// Left here for the ease of debugging
func (l *BufferList) DebugCheckHoles(s string) {
var eof uint64
l.at.Descend(0xFFFFFFFFFFFFFFFF, func(end uint64, b *FileBuffer) bool {
eof = end
return false
})
h, _, _ := l.GetHoles(0, eof)
if len(h) > 0 {
fmt.Printf("Debug: holes detected%s: %#v\n", s, h)
l.at.Ascend(0, func(end uint64, b *FileBuffer) bool {
fmt.Printf("%x-%x s%v z%v\n", b.offset, b.offset+b.length, b.state, b.zero)
return true
})
panic("holes detected")
}
}

func (l *BufferList) SplitAt(offset uint64) {
l.at.Ascend(offset+1, func(end uint64, b *FileBuffer) bool {
if b.offset < offset {
Expand Down

0 comments on commit 609c7b9

Please sign in to comment.