Skip to content

Commit

Permalink
Lock ops based on computed key rather than LLB digest
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejholly committed May 21, 2024
1 parent abb84c9 commit d4e630c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions solver/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ func (s *simpleSolver) build(ctx context.Context, job *Job, e Edge) (CachedResul
}

func (s *simpleSolver) buildOne(ctx context.Context, d digest.Digest, vertex Vertex, job *Job, e Edge) (Result, digest.Digest, error) {
// Ensure we don't have multiple threads working on the same digest.
wait, done := s.parallelGuard.acquire(ctx, d)
defer done()
<-wait

st := s.state(vertex, job)

// Add cache opts to context as they will be accessed by cache retrieval.
Expand All @@ -118,6 +113,14 @@ func (s *simpleSolver) buildOne(ctx context.Context, d digest.Digest, vertex Ver
return nil, "", err
}

// Ensure we don't have multiple threads working on the same operation. The
// computed cache key needs to be used here instead of the vertex
// digest. This is because the vertex can sometimes differ for the same
// operation depending on its ancestors.
wait, done := s.parallelGuard.acquire(ctx, cacheKey)
defer done()
<-wait

v, ok, err := s.resultSource.Load(ctx, cacheKey)
if err != nil {
return nil, "", err
Expand Down

0 comments on commit d4e630c

Please sign in to comment.