Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock ops based on computed key rather than LLB digest #61

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading