mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-18 18:25:24 -05:00
Merge pull request #18101 from roidelapluie/roidelapluie/wgGo
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
chore(lint): enable wg.Go
This commit is contained in:
commit
ece9437624
13 changed files with 38 additions and 88 deletions
|
|
@ -128,8 +128,6 @@ linters:
|
|||
# Disable this check for now since it introduces too many changes in our existing codebase.
|
||||
# See https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_omitzero for more details.
|
||||
- omitzero
|
||||
# Disable waitgroup check until we really move to Go 1.25.
|
||||
- waitgroup
|
||||
perfsprint:
|
||||
# Optimizes even if it requires an int or uint type cast.
|
||||
int-conversion: true
|
||||
|
|
|
|||
|
|
@ -159,17 +159,14 @@ func (b *writeBenchmark) ingestScrapes(lbls []labels.Labels, scrapeCount int) (u
|
|||
batch := lbls[:l]
|
||||
lbls = lbls[l:]
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
wg.Go(func() {
|
||||
n, err := b.ingestScrapesShard(batch, 100, int64(timeDelta*i))
|
||||
if err != nil {
|
||||
// exitWithError(err)
|
||||
fmt.Println(" err", err)
|
||||
}
|
||||
total.Add(n)
|
||||
}()
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1562,11 +1562,9 @@ func TestConfigReloadAndShutdownRace(t *testing.T) {
|
|||
discoveryManager.updatert = 100 * time.Millisecond
|
||||
|
||||
var wgDiscovery sync.WaitGroup
|
||||
wgDiscovery.Add(1)
|
||||
go func() {
|
||||
wgDiscovery.Go(func() {
|
||||
discoveryManager.Run()
|
||||
wgDiscovery.Done()
|
||||
}()
|
||||
})
|
||||
time.Sleep(time.Millisecond * 200)
|
||||
|
||||
var wgBg sync.WaitGroup
|
||||
|
|
@ -1588,11 +1586,9 @@ func TestConfigReloadAndShutdownRace(t *testing.T) {
|
|||
discoveryManager.ApplyConfig(c)
|
||||
|
||||
delete(c, "prometheus")
|
||||
wgBg.Add(1)
|
||||
go func() {
|
||||
wgBg.Go(func() {
|
||||
discoveryManager.ApplyConfig(c)
|
||||
wgBg.Done()
|
||||
}()
|
||||
})
|
||||
mgrCancel()
|
||||
wgDiscovery.Wait()
|
||||
|
||||
|
|
|
|||
|
|
@ -94,11 +94,9 @@ func TestQueryConcurrency(t *testing.T) {
|
|||
var wg sync.WaitGroup
|
||||
for range maxConcurrency {
|
||||
q := engine.NewTestQuery(f)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Go(func() {
|
||||
q.Exec(ctx)
|
||||
wg.Done()
|
||||
}()
|
||||
})
|
||||
select {
|
||||
case <-processing:
|
||||
// Expected.
|
||||
|
|
@ -108,11 +106,9 @@ func TestQueryConcurrency(t *testing.T) {
|
|||
}
|
||||
|
||||
q := engine.NewTestQuery(f)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Go(func() {
|
||||
q.Exec(ctx)
|
||||
wg.Done()
|
||||
}()
|
||||
})
|
||||
|
||||
select {
|
||||
case <-processing:
|
||||
|
|
|
|||
|
|
@ -2473,11 +2473,9 @@ func TestBoundedRuleEvalConcurrency(t *testing.T) {
|
|||
// Evaluate groups concurrently (like they normally do).
|
||||
var wg sync.WaitGroup
|
||||
for _, group := range groups {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Go(func() {
|
||||
group.Eval(ctx, time.Now())
|
||||
wg.Done()
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
|
|
|||
|
|
@ -111,10 +111,7 @@ func newChunkWriteQueue(reg prometheus.Registerer, size int, writeChunk writeChu
|
|||
}
|
||||
|
||||
func (c *chunkWriteQueue) start() {
|
||||
c.workerWg.Add(1)
|
||||
go func() {
|
||||
defer c.workerWg.Done()
|
||||
|
||||
c.workerWg.Go(func() {
|
||||
for {
|
||||
job, ok := c.jobs.pop()
|
||||
if !ok {
|
||||
|
|
@ -123,7 +120,7 @@ func (c *chunkWriteQueue) start() {
|
|||
|
||||
c.processJob(job)
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
c.isRunningMtx.Lock()
|
||||
c.isRunning = true
|
||||
|
|
|
|||
|
|
@ -269,34 +269,26 @@ func TestQueuePushPopManyGoroutines(t *testing.T) {
|
|||
|
||||
readersWG := sync.WaitGroup{}
|
||||
for range readGoroutines {
|
||||
readersWG.Add(1)
|
||||
|
||||
go func() {
|
||||
defer readersWG.Done()
|
||||
|
||||
readersWG.Go(func() {
|
||||
for j, ok := queue.pop(); ok; j, ok = queue.pop() {
|
||||
refsMx.Lock()
|
||||
refs[j.seriesRef] = true
|
||||
refsMx.Unlock()
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
id := atomic.Uint64{}
|
||||
|
||||
writersWG := sync.WaitGroup{}
|
||||
for range writeGoroutines {
|
||||
writersWG.Add(1)
|
||||
|
||||
go func() {
|
||||
defer writersWG.Done()
|
||||
|
||||
writersWG.Go(func() {
|
||||
for range writes {
|
||||
ref := id.Inc()
|
||||
|
||||
require.True(t, queue.push(chunkWriteJob{seriesRef: HeadSeriesRef(ref)}))
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// Wait until all writes are done.
|
||||
|
|
|
|||
|
|
@ -1717,10 +1717,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
|
|||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
wg.Go(func() {
|
||||
// Ingest sparse histograms.
|
||||
for _, ah := range allSparseSeries {
|
||||
var (
|
||||
|
|
@ -1743,7 +1740,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
|
|||
sparseULIDs, err = compactor.Write(sparseHead.opts.ChunkDirRoot, sparseHead, mint, maxt, nil)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, sparseULIDs, 1)
|
||||
}()
|
||||
})
|
||||
|
||||
wg.Add(1)
|
||||
go func(c testcase) {
|
||||
|
|
|
|||
|
|
@ -1334,13 +1334,11 @@ func TestDataMissingOnQueryDuringCompaction_AppenderV2(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
// Compacting head while the querier spans the compaction time.
|
||||
require.NoError(t, db.Compact(ctx))
|
||||
require.NotEmpty(t, db.Blocks())
|
||||
}()
|
||||
})
|
||||
|
||||
// Give enough time for compaction to finish.
|
||||
// We expect it to be blocked until querier is closed.
|
||||
|
|
|
|||
|
|
@ -3259,12 +3259,10 @@ func testHeadSeriesChunkRace(t *testing.T) {
|
|||
defer q.Close()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
h.updateMinMaxTime(20, 25)
|
||||
h.gc()
|
||||
}()
|
||||
})
|
||||
ss := q.Select(context.Background(), false, nil, matcher)
|
||||
for ss.Next() {
|
||||
}
|
||||
|
|
@ -3748,13 +3746,11 @@ func TestChunkNotFoundHeadGCRace(t *testing.T) {
|
|||
s := ss.At()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
// Compacting head while the querier spans the compaction time.
|
||||
require.NoError(t, db.Compact(ctx))
|
||||
require.NotEmpty(t, db.Blocks())
|
||||
}()
|
||||
})
|
||||
|
||||
// Give enough time for compaction to finish.
|
||||
// We expect it to be blocked until querier is closed.
|
||||
|
|
@ -3812,13 +3808,11 @@ func TestDataMissingOnQueryDuringCompaction(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
// Compacting head while the querier spans the compaction time.
|
||||
require.NoError(t, db.Compact(ctx))
|
||||
require.NotEmpty(t, db.Blocks())
|
||||
}()
|
||||
})
|
||||
|
||||
// Give enough time for compaction to finish.
|
||||
// We expect it to be blocked until querier is closed.
|
||||
|
|
|
|||
|
|
@ -88,10 +88,7 @@ func BenchmarkIsolation(b *testing.B) {
|
|||
start := make(chan struct{})
|
||||
|
||||
for range goroutines {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
|
||||
for b.Loop() {
|
||||
|
|
@ -99,7 +96,7 @@ func BenchmarkIsolation(b *testing.B) {
|
|||
|
||||
iso.closeAppend(appendID)
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
|
@ -118,10 +115,7 @@ func BenchmarkIsolationWithState(b *testing.B) {
|
|||
start := make(chan struct{})
|
||||
|
||||
for range goroutines {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
|
||||
for b.Loop() {
|
||||
|
|
@ -129,7 +123,7 @@ func BenchmarkIsolationWithState(b *testing.B) {
|
|||
|
||||
iso.closeAppend(appendID)
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
readers := goroutines / 100
|
||||
|
|
@ -138,17 +132,14 @@ func BenchmarkIsolationWithState(b *testing.B) {
|
|||
}
|
||||
|
||||
for g := 0; g < readers; g++ {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
|
||||
for b.Loop() {
|
||||
s := iso.State(math.MinInt64, math.MaxInt64)
|
||||
s.Close()
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
|
|
|||
|
|
@ -265,8 +265,7 @@ func (tc *ZookeeperTreeCache) recursiveNodeUpdate(path string, node *zookeeperTr
|
|||
}
|
||||
}
|
||||
|
||||
tc.wg.Add(1)
|
||||
go func() {
|
||||
tc.wg.Go(func() {
|
||||
numWatchers.Inc()
|
||||
// Pass up zookeeper events, until the node is deleted.
|
||||
select {
|
||||
|
|
@ -277,8 +276,7 @@ func (tc *ZookeeperTreeCache) recursiveNodeUpdate(path string, node *zookeeperTr
|
|||
case <-node.done:
|
||||
}
|
||||
numWatchers.Dec()
|
||||
tc.wg.Done()
|
||||
}()
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -503,14 +503,12 @@ func TestHandleMultipleQuitRequests(t *testing.T) {
|
|||
start := make(chan struct{})
|
||||
var wg sync.WaitGroup
|
||||
for range 3 {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
resp, err := http.Post(baseURL+"/-/quit", "", strings.NewReader(""))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
}()
|
||||
})
|
||||
}
|
||||
close(start)
|
||||
wg.Wait()
|
||||
|
|
|
|||
Loading…
Reference in a new issue