Skip to content

Commit

Permalink
Merge pull request #2556 from hinshun/scheduler-inf-loop
Browse files Browse the repository at this point in the history
Remove goto statements causing failed edges to never unpark
  • Loading branch information
tonistiigi authored Jan 13, 2022
2 parents ffe2301 + 465a30a commit e5e39c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 5 additions & 1 deletion solver/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type edge struct {
index *edgeIndex

secondaryExporters []expDep

failedOnce sync.Once
}

// dep holds state for a dependant edge
Expand Down Expand Up @@ -375,7 +377,9 @@ func (e *edge) makeExportable(k *CacheKey, records []*CacheRecord) ExportableCac

func (e *edge) markFailed(f *pipeFactory, err error) {
e.err = err
e.postpone(f)
e.failedOnce.Do(func() {
e.postpone(f)
})
}

// processUpdate is called by unpark for every updated pipe request
Expand Down
3 changes: 0 additions & 3 deletions solver/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func (s *scheduler) dispatch(e *edge) {
debugSchedulerPostUnpark(e, inc)
}

postUnpark:
// set up new requests that didn't complete/were added by this run
openIncoming := make([]*edgePipe, 0, len(inc))
for _, r := range s.incoming[e] {
Expand Down Expand Up @@ -189,11 +188,9 @@ postUnpark:
// unpark(), not for any external input.
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"))
goto postUnpark
}
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"))
goto postUnpark
}
}

Expand Down

0 comments on commit e5e39c3

Please sign in to comment.