|
|
|
|
@ -1875,70 +1875,3 @@ func TestHeadLabelNamesValuesWithMinMaxRange(t *testing.T) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestHeadCompactionRace(t *testing.T) { |
|
|
|
|
// There are still some races to be fixed. Hence skipping this test
|
|
|
|
|
// for now to not cause flaky CI failures.
|
|
|
|
|
t.Skip() |
|
|
|
|
|
|
|
|
|
for i := 0; i < 10; i++ { |
|
|
|
|
t.Run(fmt.Sprintf("run %d", i), func(t *testing.T) { |
|
|
|
|
tsdbCfg := &Options{ |
|
|
|
|
RetentionDuration: 100000000, |
|
|
|
|
NoLockfile: true, |
|
|
|
|
MinBlockDuration: 1000000, |
|
|
|
|
MaxBlockDuration: 1000000, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
db, closer := openTestDB(t, tsdbCfg, []int64{1000000}) |
|
|
|
|
t.Cleanup(closer) |
|
|
|
|
t.Cleanup(func() { |
|
|
|
|
testutil.Ok(t, db.Close()) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
head := db.Head() |
|
|
|
|
|
|
|
|
|
// Get past the init appender phase here.
|
|
|
|
|
app := head.Appender() |
|
|
|
|
_, err := app.Add(labels.Labels{labels.Label{Name: "n", Value: "v"}}, 10, 10) |
|
|
|
|
testutil.Ok(t, err) |
|
|
|
|
testutil.Ok(t, app.Commit()) |
|
|
|
|
|
|
|
|
|
wait := make(chan struct{}) |
|
|
|
|
var wg sync.WaitGroup |
|
|
|
|
|
|
|
|
|
// Prepare to execute concurrent appends.
|
|
|
|
|
wg.Add(100) |
|
|
|
|
for i := 0; i < 100; i++ { |
|
|
|
|
go func(idx int) { |
|
|
|
|
defer wg.Done() |
|
|
|
|
app := head.Appender() |
|
|
|
|
<-wait |
|
|
|
|
|
|
|
|
|
for j := 0; j < 100; j++ { |
|
|
|
|
// After compaction this will return out of bound, so this is a best effort append.
|
|
|
|
|
app.Add(labels.Labels{labels.Label{ |
|
|
|
|
Name: fmt.Sprintf("n%d", idx*100+j), |
|
|
|
|
Value: fmt.Sprintf("v%d", idx*100+j), |
|
|
|
|
}}, 1000, 10) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testutil.Ok(t, app.Commit()) |
|
|
|
|
}(i) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Prepare for head compaction.
|
|
|
|
|
wg.Add(1) |
|
|
|
|
go func() { |
|
|
|
|
defer wg.Done() |
|
|
|
|
<-wait |
|
|
|
|
testutil.Ok(t, db.CompactHead(NewRangeHead(head, 0, 10000000))) |
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
// Run concurrent appends and compaction.
|
|
|
|
|
close(wait) |
|
|
|
|
|
|
|
|
|
wg.Wait() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|