diff --git a/db.go b/db.go index 2491ce145..010a5968d 100644 --- a/db.go +++ b/db.go @@ -261,7 +261,7 @@ func OpenShard(path string, i int, logger log.Logger) (*Shard, error) { s := &Shard{ path: path, logger: logger, - metrics: newShardMetrics(prometheus.DefaultRegisterer, i), + metrics: newShardMetrics(nil, i), heads: heads, persisted: persisted, cutc: make(chan struct{}, 1), @@ -335,7 +335,7 @@ func (s *Shard) appendBatch(samples []hashedSample) error { } // TODO(fabxc): randomize over time and use better scoring function. - if head.bstats.SampleCount/(uint64(head.bstats.ChunkCount)+1) > 400 { + if head.bstats.SampleCount/(uint64(head.bstats.ChunkCount)+1) > 500 { if err := s.cut(); err != nil { s.logger.Log("msg", "cut failed", "err", err) } diff --git a/querier.go b/querier.go index 4cacc7631..f6383b186 100644 --- a/querier.go +++ b/querier.go @@ -381,7 +381,7 @@ func (s *shardSeriesSet) compare() int { if s.bdone { return -1 } - return labels.Compare(s.a.At().Labels(), s.a.At().Labels()) + return labels.Compare(s.a.At().Labels(), s.b.At().Labels()) } func (s *shardSeriesSet) Next() bool { diff --git a/querier_test.go b/querier_test.go index 1ad093bb7..842f8c73f 100644 --- a/querier_test.go +++ b/querier_test.go @@ -139,6 +139,57 @@ func TestShardSeriesSet(t *testing.T) { }), }), }, + { + a: newListSeriesSet([]Series{ + newSeries(map[string]string{ + "handler": "prometheus", + "instance": "127.0.0.1:9090", + }, []sample{ + {t: 1, v: 1}, + }), + newSeries(map[string]string{ + "handler": "prometheus", + "instance": "localhost:9090", + }, []sample{ + {t: 1, v: 2}, + }), + }), + b: newListSeriesSet([]Series{ + newSeries(map[string]string{ + "handler": "prometheus", + "instance": "127.0.0.1:9090", + }, []sample{ + {t: 2, v: 1}, + }), + newSeries(map[string]string{ + "handler": "query", + "instance": "localhost:9090", + }, []sample{ + {t: 2, v: 2}, + }), + }), + exp: newListSeriesSet([]Series{ + newSeries(map[string]string{ + "handler": "prometheus", + "instance": "127.0.0.1:9090", + }, []sample{ + {t: 1, v: 1}, + {t: 2, v: 1}, + }), + newSeries(map[string]string{ + "handler": "prometheus", + "instance": "localhost:9090", + }, []sample{ + {t: 1, v: 2}, + }), + newSeries(map[string]string{ + "handler": "query", + "instance": "localhost:9090", + }, []sample{ + {t: 2, v: 2}, + }), + }), + }, } Outer: