fix: improve comment wording and strengthen race test start barrier

Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/9e4d6f4f-cdc1-4e9e-bdc6-81061ebc1dcc

Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-13 00:15:53 +00:00 committed by yxxhero
parent 9685c1442b
commit a1c90de8f3
2 changed files with 10 additions and 4 deletions

View File

@ -528,18 +528,22 @@ dependencies:
}
// Run multiple goroutines concurrently on the same chart path.
// A start barrier ensures all goroutines attempt rewriteChartDependencies simultaneously.
// A readiness WaitGroup ensures all goroutines are blocked before the start barrier is released,
// so calls to rewriteChartDependencies overlap as much as possible.
numGoroutines := 10
var wg sync.WaitGroup
var readyWg sync.WaitGroup
errCh := make(chan error, numGoroutines)
ready := make(chan struct{})
for i := 0; i < numGoroutines; i++ {
wg.Add(1)
readyWg.Add(1)
go func() {
defer wg.Done()
// Wait until all goroutines are ready so they start simultaneously.
// Signal that this goroutine is ready, then wait for the start signal.
readyWg.Done()
<-ready
logger := zap.NewNop().Sugar()
@ -557,7 +561,8 @@ dependencies:
}()
}
// Release all goroutines at once to maximize contention.
// Wait until all goroutines are ready, then release them simultaneously.
readyWg.Wait()
close(ready)
wg.Wait()

View File

@ -1473,7 +1473,8 @@ func (st *HelmState) rewriteChartDependencies(chartPath string) (func(), error)
}
}
// If nothing changed, release the lock immediately no file I/O or lock held by caller needed.
// If nothing changed, release the lock immediately. Chart.yaml has already been read and
// unmarshaled above, but no file write is needed and the lock is not held beyond this function.
if !modified {
mu.Unlock()
return func() {}, nil