@ -2041,8 +2041,9 @@ func (db *DB) Querier(mint, maxt int64) (_ storage.Querier, err error) {
}
} ( )
overlapsOOO := overlapsClosedInterval ( mint , maxt , db . head . MinOOOTime ( ) , db . head . MaxOOOTime ( ) )
var headQuerier storage . Querier
if maxt >= db . head . MinTime ( ) {
if maxt >= db . head . MinTime ( ) || overlapsOOO {
rh := NewRangeHead ( db . head , mint , maxt )
var err error
headQuerier , err = db . blockQuerierFunc ( rh , mint , maxt )
@ -2069,23 +2070,11 @@ func (db *DB) Querier(mint, maxt int64) (_ storage.Querier, err error) {
}
}
if headQuerier != nil {
if overlapsClosedInterval ( mint , maxt , db . head . MinOOOTime ( ) , db . head . MaxOOOTime ( ) ) {
if overlapsOOO {
// We need to fetch from in-order and out-of-order chunks: wrap the headQuerier.
isoState := db . head . oooIso . TrackReadAfter ( db . lastGarbageCollectedMmapRef )
headQuerier = NewHeadAndOOOQuerier ( mint , maxt , db . head , isoState , headQuerier )
}
} else if overlapsClosedInterval ( mint , maxt , db . head . MinOOOTime ( ) , db . head . MaxOOOTime ( ) ) {
rh := NewOOORangeHead ( db . head , mint , maxt , db . lastGarbageCollectedMmapRef )
var err error
headQuerier , err = db . blockQuerierFunc ( rh , mint , maxt )
if err != nil {
// If BlockQuerierFunc() failed, make sure to clean up the pending read created by NewOOORangeHead.
rh . isoState . Close ( )
return nil , fmt . Errorf ( "open block querier for ooo head %s: %w" , rh , err )
}
}
if headQuerier != nil {
blockQueriers = append ( blockQueriers , headQuerier )
@ -2128,8 +2117,9 @@ func (db *DB) blockChunkQuerierForRange(mint, maxt int64) (_ []storage.ChunkQuer
}
} ( )
overlapsOOO := overlapsClosedInterval ( mint , maxt , db . head . MinOOOTime ( ) , db . head . MaxOOOTime ( ) )
var headQuerier storage . ChunkQuerier
if maxt >= db . head . MinTime ( ) {
if maxt >= db . head . MinTime ( ) || overlapsOOO {
rh := NewRangeHead ( db . head , mint , maxt )
headQuerier , err = db . blockChunkQuerierFunc ( rh , mint , maxt )
if err != nil {
@ -2155,22 +2145,11 @@ func (db *DB) blockChunkQuerierForRange(mint, maxt int64) (_ []storage.ChunkQuer
}
}
if headQuerier != nil {
if overlapsClosedInterval ( mint , maxt , db . head . MinOOOTime ( ) , db . head . MaxOOOTime ( ) ) {
if overlapsOOO {
// We need to fetch from in-order and out-of-order chunks: wrap the headQuerier.
isoState := db . head . oooIso . TrackReadAfter ( db . lastGarbageCollectedMmapRef )
headQuerier = NewHeadAndOOOChunkQuerier ( mint , maxt , db . head , isoState , headQuerier )
}
} else if overlapsClosedInterval ( mint , maxt , db . head . MinOOOTime ( ) , db . head . MaxOOOTime ( ) ) {
rh := NewOOORangeHead ( db . head , mint , maxt , db . lastGarbageCollectedMmapRef )
headQuerier , err = db . blockChunkQuerierFunc ( rh , mint , maxt )
if err != nil {
// If NewBlockQuerier() failed, make sure to clean up the pending read created by NewOOORangeHead.
rh . isoState . Close ( )
return nil , fmt . Errorf ( "open block chunk querier for ooo head %s: %w" , rh , err )
}
}
if headQuerier != nil {
blockQueriers = append ( blockQueriers , headQuerier )