mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
This reverts commit 30505a202a
.
This commit is contained in:
parent
190addffd8
commit
492061b24c
|
@ -1692,6 +1692,8 @@ func (h *Head) getOrCreateWithID(id, hash uint64, lset labels.Labels) (*memSerie
|
||||||
h.metrics.seriesCreated.Inc()
|
h.metrics.seriesCreated.Inc()
|
||||||
atomic.AddUint64(&h.numSeries, 1)
|
atomic.AddUint64(&h.numSeries, 1)
|
||||||
|
|
||||||
|
h.postings.Add(id, lset)
|
||||||
|
|
||||||
h.symMtx.Lock()
|
h.symMtx.Lock()
|
||||||
defer h.symMtx.Unlock()
|
defer h.symMtx.Unlock()
|
||||||
|
|
||||||
|
@ -1707,10 +1709,6 @@ func (h *Head) getOrCreateWithID(id, hash uint64, lset labels.Labels) (*memSerie
|
||||||
h.symbols[l.Value] = struct{}{}
|
h.symbols[l.Value] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Postings should be set after setting the symbols (or after holding
|
|
||||||
// the symbol mtx) to avoid race during compaction of seeing partial symbols.
|
|
||||||
h.postings.Add(id, lset)
|
|
||||||
|
|
||||||
return s, true, nil
|
return s, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue