Protect NewOOOCompactionHead from an unitialized wbl

Signed-off-by: Jesus Vazquez <jesus.vazquez@grafana.com>
This commit is contained in:
Jesus Vazquez 2023-02-10 12:52:12 +01:00
parent 36b04efc7b
commit f269077855

View file

@ -276,16 +276,18 @@ type OOOCompactionHead struct {
// All the above together have a bit of CPU and memory overhead, and can have a bit of impact
// on the sample append latency. So call NewOOOCompactionHead only right before compaction.
func NewOOOCompactionHead(head *Head) (*OOOCompactionHead, error) {
newWBLFile, err := head.wbl.NextSegmentSync()
if err != nil {
return nil, err
}
ch := &OOOCompactionHead{
chunkRange: head.chunkRange.Load(),
mint: math.MaxInt64,
maxt: math.MinInt64,
lastWBLFile: newWBLFile,
lastWBLFile: 0,
}
if head.wbl != nil {
lastWBLFile, err := head.wbl.NextSegmentSync()
if err != nil {
return nil, err
}
ch.lastWBLFile = lastWBLFile
}
ch.oooIR = NewOOOHeadIndexReader(head, math.MinInt64, math.MaxInt64)