mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Fix and test bug in shardSeriesSet
This commit is contained in:
parent
ac49f8c15e
commit
ec99f99d3d
4
db.go
4
db.go
|
@ -261,7 +261,7 @@ func OpenShard(path string, i int, logger log.Logger) (*Shard, error) {
|
||||||
s := &Shard{
|
s := &Shard{
|
||||||
path: path,
|
path: path,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
metrics: newShardMetrics(prometheus.DefaultRegisterer, i),
|
metrics: newShardMetrics(nil, i),
|
||||||
heads: heads,
|
heads: heads,
|
||||||
persisted: persisted,
|
persisted: persisted,
|
||||||
cutc: make(chan struct{}, 1),
|
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.
|
// 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 {
|
if err := s.cut(); err != nil {
|
||||||
s.logger.Log("msg", "cut failed", "err", err)
|
s.logger.Log("msg", "cut failed", "err", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ func (s *shardSeriesSet) compare() int {
|
||||||
if s.bdone {
|
if s.bdone {
|
||||||
return -1
|
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 {
|
func (s *shardSeriesSet) Next() bool {
|
||||||
|
|
|
@ -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:
|
Outer:
|
||||||
|
|
Loading…
Reference in a new issue