mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
tsdb tests: avoid capture-by-reference in goroutines
Only one version of the variable is captured; this is a source of race conditions. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
54cf0d6879
commit
f4fbe47254
|
@ -1575,12 +1575,13 @@ func TestHeadCompactionWithHistograms(t *testing.T) {
|
||||||
func TestSparseHistogramSpaceSavings(t *testing.T) {
|
func TestSparseHistogramSpaceSavings(t *testing.T) {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
|
|
||||||
cases := []struct {
|
type testcase struct {
|
||||||
numSeriesPerSchema int
|
numSeriesPerSchema int
|
||||||
numBuckets int
|
numBuckets int
|
||||||
numSpans int
|
numSpans int
|
||||||
gapBetweenSpans int
|
gapBetweenSpans int
|
||||||
}{
|
}
|
||||||
|
cases := []testcase{
|
||||||
{1, 15, 1, 0},
|
{1, 15, 1, 0},
|
||||||
{1, 50, 1, 0},
|
{1, 50, 1, 0},
|
||||||
{1, 100, 1, 0},
|
{1, 100, 1, 0},
|
||||||
|
@ -1692,7 +1693,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func(c testcase) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
// Ingest histograms the old way.
|
// Ingest histograms the old way.
|
||||||
|
@ -1740,7 +1741,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
|
||||||
oldULIDs, err = compactor.Write(oldHead.opts.ChunkDirRoot, oldHead, mint, maxt, nil)
|
oldULIDs, err = compactor.Write(oldHead.opts.ChunkDirRoot, oldHead, mint, maxt, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, oldULIDs, 1)
|
require.Len(t, oldULIDs, 1)
|
||||||
}()
|
}(c)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|
|
@ -694,9 +694,9 @@ func (h *Head) loadWBL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(decodedCh)
|
defer close(decodedCh)
|
||||||
var err error
|
|
||||||
dec := record.NewDecoder(syms)
|
dec := record.NewDecoder(syms)
|
||||||
for r.Next() {
|
for r.Next() {
|
||||||
|
var err error
|
||||||
rec := r.Record()
|
rec := r.Record()
|
||||||
switch dec.Type(rec) {
|
switch dec.Type(rec) {
|
||||||
case record.Samples:
|
case record.Samples:
|
||||||
|
|
Loading…
Reference in a new issue