diff --git a/head.go b/head.go index 30cbe61e2..92619a640 100644 --- a/head.go +++ b/head.go @@ -421,6 +421,10 @@ func (h *Head) loadWAL(r *wal.Reader) error { if itv.Maxt < h.minValidTime { continue } + if m := h.series.getByID(s.ref); m == nil { + unknownRefs++ + continue + } allStones.addInterval(s.ref, itv) } } diff --git a/head_test.go b/head_test.go index 9e78b6b62..79092dd5c 100644 --- a/head_test.go +++ b/head_test.go @@ -114,6 +114,9 @@ func TestHead_ReadWAL(t *testing.T) { {Ref: 10, T: 101, V: 5}, {Ref: 50, T: 101, V: 6}, }, + []Stone{ + {ref: 0, intervals: []Interval{{Mint: 99, Maxt: 101}}}, + }, } dir, err := ioutil.TempDir("", "test_read_wal") testutil.Ok(t, err)