Open jedevc opened 9 months ago
I also found this while working on this, related but a bit different (also not sure if it's even valid):
func TestImmediateCancel(t *testing.T) {
t.Parallel()
for i := 0; i < 10000; i++ {
ctx := context.TODO()
cacheManager := newTrackingCacheManager(NewInMemoryCacheManager())
l := NewSolver(SolverOpt{
ResolveOpFunc: testOpResolver,
DefaultCache: cacheManager,
})
defer l.Close()
j0, err := l.NewJob("j0")
require.NoError(t, err)
g := Edge{
Vertex: vtxSum(1, vtxOpt{
inputs: []Edge{
{Vertex: vtxConst(3, vtxOpt{})},
{Vertex: vtxConst(2, vtxOpt{})},
},
}),
}
// is it valid to call discard in parallel with Build?
go j0.Discard()
_, err = j0.Build(ctx, g)
require.NoError(t, err)
}
}
$ go test -run "TestImmediateCancel$" -v
=== RUN TestImmediateCancel
=== PAUSE TestImmediateCancel
=== CONT TestImmediateCancel
scheduler_test.go:3294:
Error Trace: /home/jedevc/Documents/Projects/moby/buildkit/solver/scheduler_test.go:3294
Error: Received unexpected error:
failed to get edge: inconsistent graph state
github.com/moby/buildkit/solver.(*pipeFactory).NewInputRequest.func1
/home/jedevc/Documents/Projects/moby/buildkit/solver/scheduler.go:373
github.com/moby/buildkit/solver/internal/pipe.NewWithFunction.func2
/home/jedevc/Documents/Projects/moby/buildkit/solver/internal/pipe/pipe.go:82
runtime.goexit
/usr/lib/go/src/runtime/asm_amd64.s:1695
Test: TestImmediateCancel
--- FAIL: TestImmediateCancel (0.00s)
FAIL
exit status 1
FAIL github.com/moby/buildkit/solver 0.009s
Bit of a brain dump - while exploring another related scheduler bug (attempting to investigate https://github.com/moby/buildkit/issues/3635), I managed to construct an interesting (and very reproducible!) test case that could potentially occur:
This fails with:
Maybe a bit of an edge case? But also this does seem to reproduce fairly consistently, and could potentially be another nastier issue.