-
Notifications
You must be signed in to change notification settings - Fork 178
Keep series that are still in WAL in checkpoints #577
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,6 +501,57 @@ func TestDeleteUntilCurMax(t *testing.T) { | |
testutil.Ok(t, err) | ||
testutil.Equals(t, []tsdbutil.Sample{sample{11, 1}}, ressmpls) | ||
} | ||
|
||
func TestDeletedSamplesAndSeriesStillInWALAfterCheckpoint(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe extend the test a bit like: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure what you're getting at. There are no existing series after we've read the checkpoint, as we've deleted them. |
||
dir, err := ioutil.TempDir("", "test_delete_wal") | ||
testutil.Ok(t, err) | ||
defer func() { | ||
testutil.Ok(t, os.RemoveAll(dir)) | ||
}() | ||
wlog, err := wal.NewSize(nil, nil, dir, 32768) | ||
testutil.Ok(t, err) | ||
|
||
// Enough samples to cause a checkpoint. | ||
numSamples := 10000 | ||
hb, err := NewHead(nil, nil, wlog, int64(numSamples)*10) | ||
testutil.Ok(t, err) | ||
defer hb.Close() | ||
for i := 0; i < numSamples; i++ { | ||
app := hb.Appender() | ||
_, err := app.Add(labels.Labels{{"a", "b"}}, int64(i), 0) | ||
testutil.Ok(t, err) | ||
testutil.Ok(t, app.Commit()) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets extract all this in a separate func like in my other PR
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd clash with the existing name, plus that function doesn't have the WAL handling I need. |
||
testutil.Ok(t, hb.Delete(0, int64(numSamples), labels.NewEqualMatcher("a", "b"))) | ||
testutil.Ok(t, hb.Truncate(1)) | ||
testutil.Ok(t, hb.Close()) | ||
|
||
// Confirm there's been a checkpoint. | ||
cdir, _, err := LastCheckpoint(dir) | ||
testutil.Ok(t, err) | ||
// Read in checkpoint and WAL. | ||
recs := readTestWAL(t, cdir) | ||
recs = append(recs, readTestWAL(t, dir)...) | ||
|
||
var series, samples, stones int | ||
for _, rec := range recs { | ||
switch rec.(type) { | ||
case []RefSeries: | ||
series++ | ||
case []RefSample: | ||
samples++ | ||
case []Stone: | ||
stones++ | ||
default: | ||
t.Fatalf("unknown record type") | ||
} | ||
} | ||
testutil.Equals(t, 1, series) | ||
testutil.Equals(t, 9999, samples) | ||
testutil.Equals(t, 1, stones) | ||
|
||
} | ||
|
||
func TestDelete_e2e(t *testing.T) { | ||
numDatapoints := 1000 | ||
numRanges := 1000 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be kept until what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your suggestion doesn't make sense. This is a data structure, not an algorithm.