[bugfix] update 'last' variable in chunks.MergeOverlappingChunks() (#539)
* update Signed-off-by: naivewong <867245430@qq.com> * update comment Signed-off-by: naivewong <867245430@qq.com> * Update failing test. Signed-off-by: naivewong <867245430@qq.com> * Update comment Signed-off-by: naivewong <867245430@qq.com> * Add changelog entry. Signed-off-by: naivewong <867245430@qq.com> * Update CHANGELOG.md Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
This commit is contained in:
parent
08af7bbf90
commit
0861a9b14f
|
@ -1,4 +1,5 @@
|
|||
## master / unreleased
|
||||
- [BUGFIX] Update `last` after appending a non-overlapping chunk in `chunks.MergeOverlappingChunks`. [#539](https://github.com/prometheus/tsdb/pull/539)
|
||||
|
||||
## 0.6.0
|
||||
- [CHANGE] `AllowOverlappingBlock` is now `AllowOverlappingBlocks`.
|
||||
|
|
|
@ -213,6 +213,7 @@ func MergeOverlappingChunks(chks []Meta) ([]Meta, error) {
|
|||
// So never overlaps with newChks[last-1] or anything before that.
|
||||
if c.MinTime > newChks[last].MaxTime {
|
||||
newChks = append(newChks, c)
|
||||
last += 1
|
||||
continue
|
||||
}
|
||||
nc := &newChks[last]
|
||||
|
|
|
@ -653,7 +653,8 @@ func TestCompaction_populateBlock(t *testing.T) {
|
|||
expErr: errors.New("found chunk with minTime: 10 maxTime: 20 outside of compacted minTime: 0 maxTime: 10"),
|
||||
},
|
||||
{
|
||||
// No special deduplication expected.
|
||||
// Deduplication expected.
|
||||
// Introduced by pull/370 and pull/539.
|
||||
title: "Populate from two blocks containing duplicated chunk.",
|
||||
inputSeriesSamples: [][]seriesSamples{
|
||||
{
|
||||
|
@ -672,7 +673,53 @@ func TestCompaction_populateBlock(t *testing.T) {
|
|||
expSeriesSamples: []seriesSamples{
|
||||
{
|
||||
lset: map[string]string{"a": "b"},
|
||||
chunks: [][]sample{{{t: 1}, {t: 2}}, {{t: 10}, {t: 20}}, {{t: 10}, {t: 20}}},
|
||||
chunks: [][]sample{{{t: 1}, {t: 2}}, {{t: 10}, {t: 20}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Introduced by https://github.com/prometheus/tsdb/pull/539.
|
||||
title: "Populate from three blocks that the last two are overlapping.",
|
||||
inputSeriesSamples: [][]seriesSamples{
|
||||
{
|
||||
{
|
||||
lset: map[string]string{"before": "fix"},
|
||||
chunks: [][]sample{{{t: 0}, {t: 10}, {t: 11}, {t: 20}}},
|
||||
},
|
||||
{
|
||||
lset: map[string]string{"after": "fix"},
|
||||
chunks: [][]sample{{{t: 0}, {t: 10}, {t: 11}, {t: 20}}},
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
lset: map[string]string{"before": "fix"},
|
||||
chunks: [][]sample{{{t: 19}, {t: 30}}},
|
||||
},
|
||||
{
|
||||
lset: map[string]string{"after": "fix"},
|
||||
chunks: [][]sample{{{t: 21}, {t: 30}}},
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
lset: map[string]string{"before": "fix"},
|
||||
chunks: [][]sample{{{t: 27}, {t: 35}}},
|
||||
},
|
||||
{
|
||||
lset: map[string]string{"after": "fix"},
|
||||
chunks: [][]sample{{{t: 27}, {t: 35}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
expSeriesSamples: []seriesSamples{
|
||||
{
|
||||
lset: map[string]string{"after": "fix"},
|
||||
chunks: [][]sample{{{t: 0}, {t: 10}, {t: 11}, {t: 20}}, {{t: 21}, {t: 27}, {t: 30}, {t: 35}}},
|
||||
},
|
||||
{
|
||||
lset: map[string]string{"before": "fix"},
|
||||
chunks: [][]sample{{{t: 0}, {t: 10}, {t: 11}, {t: 19}, {t: 20}, {t: 27}, {t: 30}, {t: 35}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue