diff --git a/head.go b/head.go index 1b8af29f0..5eafb4f95 100644 --- a/head.go +++ b/head.go @@ -403,9 +403,6 @@ func (h *HeadBlock) fullness() float64 { } func (h *HeadBlock) updateMapping() { - h.mapper.mtx.Lock() - defer h.mapper.mtx.Unlock() - h.mtx.RLock() if h.mapper.sortable != nil && h.mapper.Len() == len(h.descs) { @@ -435,15 +432,12 @@ func (h *HeadBlock) remapPostings(p Postings) Postings { return errPostings{err: err} } - h.mapper.mtx.RLock() - defer h.mapper.mtx.RUnlock() + h.mapper.mtx.Lock() + defer h.mapper.mtx.Unlock() + h.updateMapping() h.mapper.Sort(list) - slice.Sort(list, func(i, j int) bool { - return h.mapper.fw[list[i]] < h.mapper.fw[list[j]] - }) - return newListPostings(list) } diff --git a/querier.go b/querier.go index 73158b6ec..bbbc7abf3 100644 --- a/querier.go +++ b/querier.go @@ -64,11 +64,8 @@ func (s *DB) Querier(mint, maxt int64) Querier { // TODO(fabxc): find nicer solution. if hb, ok := b.(*HeadBlock); ok { - hb.updateMapping() q.postingsMapper = hb.remapPostings - q.series = &headSeriesReader{ - h: hb, - } + q.series = &headSeriesReader{h: hb} } sq.blocks = append(sq.blocks, q)