Merge pull request #2556 from hinshun/scheduler-inf-loop

Remove goto statements causing failed edges to never unpark
master
Tõnis Tiigi 2022-01-12 16:53:36 -08:00 committed by GitHub
commit e5e39c3319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -68,6 +68,8 @@ type edge struct {
index *edgeIndex index *edgeIndex
secondaryExporters []expDep secondaryExporters []expDep
failedOnce sync.Once
} }
// dep holds state for a dependant edge // dep holds state for a dependant edge
@ -375,7 +377,9 @@ func (e *edge) makeExportable(k *CacheKey, records []*CacheRecord) ExportableCac
func (e *edge) markFailed(f *pipeFactory, err error) { func (e *edge) markFailed(f *pipeFactory, err error) {
e.err = err e.err = err
e.failedOnce.Do(func() {
e.postpone(f) e.postpone(f)
})
} }
// processUpdate is called by unpark for every updated pipe request // processUpdate is called by unpark for every updated pipe request

View File

@ -138,7 +138,6 @@ func (s *scheduler) dispatch(e *edge) {
debugSchedulerPostUnpark(e, inc) debugSchedulerPostUnpark(e, inc)
} }
postUnpark:
// set up new requests that didn't complete/were added by this run // set up new requests that didn't complete/were added by this run
openIncoming := make([]*edgePipe, 0, len(inc)) openIncoming := make([]*edgePipe, 0, len(inc))
for _, r := range s.incoming[e] { for _, r := range s.incoming[e] {
@ -189,11 +188,9 @@ postUnpark:
// unpark(), not for any external input. // unpark(), not for any external input.
if len(openIncoming) > 0 && len(openOutgoing) == 0 { if len(openIncoming) > 0 && len(openOutgoing) == 0 {
e.markFailed(pf, errors.New("buildkit scheduler error: return leaving incoming open. Please report this with BUILDKIT_SCHEDULER_DEBUG=1")) e.markFailed(pf, errors.New("buildkit scheduler error: return leaving incoming open. Please report this with BUILDKIT_SCHEDULER_DEBUG=1"))
goto postUnpark
} }
if len(openIncoming) == 0 && len(openOutgoing) > 0 { if len(openIncoming) == 0 && len(openOutgoing) > 0 {
e.markFailed(pf, errors.New("buildkit scheduler error: return leaving outgoing open. Please report this with BUILDKIT_SCHEDULER_DEBUG=1")) e.markFailed(pf, errors.New("buildkit scheduler error: return leaving outgoing open. Please report this with BUILDKIT_SCHEDULER_DEBUG=1"))
goto postUnpark
} }
} }