Correctly handle pruning wraparound after ring expansion (#3942)

Fixes #3939
This commit is contained in:
Brian Brazil 2018-03-12 13:16:59 +00:00 committed by GitHub
parent 85a3c974b7
commit a8c22c85cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -178,6 +178,7 @@ func (r *sampleRing) add(t int64, v float64) {
r.buf = buf
r.i = r.f
r.f += l
l = 2 * l
} else {
r.i++
if r.i >= l {

View file

@ -48,6 +48,11 @@ func TestSampleRing(t *testing.T) {
delta: 7,
size: 1,
},
{
input: []int64{1, 2, 3, 4, 6},
delta: 4,
size: 4,
},
}
for _, c := range cases {
r := newSampleRing(c.delta, c.size)