Don't crash on an unknown tombstone ref. (#604)

Fixes https://github.com/prometheus/prometheus/issues/5562

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
Brian Brazil 2019-05-16 14:36:44 +01:00 committed by Krasi Georgiev
parent 63d9c2ab18
commit 30d0ea59d7
2 changed files with 7 additions and 0 deletions

View file

@ -421,6 +421,10 @@ func (h *Head) loadWAL(r *wal.Reader) error {
if itv.Maxt < h.minValidTime { if itv.Maxt < h.minValidTime {
continue continue
} }
if m := h.series.getByID(s.ref); m == nil {
unknownRefs++
continue
}
allStones.addInterval(s.ref, itv) allStones.addInterval(s.ref, itv)
} }
} }

View file

@ -114,6 +114,9 @@ func TestHead_ReadWAL(t *testing.T) {
{Ref: 10, T: 101, V: 5}, {Ref: 10, T: 101, V: 5},
{Ref: 50, T: 101, V: 6}, {Ref: 50, T: 101, V: 6},
}, },
[]Stone{
{ref: 0, intervals: []Interval{{Mint: 99, Maxt: 101}}},
},
} }
dir, err := ioutil.TempDir("", "test_read_wal") dir, err := ioutil.TempDir("", "test_read_wal")
testutil.Ok(t, err) testutil.Ok(t, err)