From 4c0fd4bb60ad179a6cf6be0edf416b2fca287b40 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 8 Jan 2024 11:36:44 +0100 Subject: pkg/repro: fix potential deadlock If an instance fails to boot 3 times in a row, we drop it on the floor. If we drop all instances this way, the repro process deadlocks infinitly. Retry infinitly instead. There is nothing else good we can do in this case. If the instances becomes alive again, repro will resume. --- pkg/repro/repro.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'pkg') diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go index 9f0faf29c..5cfa7acda 100644 --- a/pkg/repro/repro.go +++ b/pkg/repro/repro.go @@ -612,8 +612,8 @@ func (ctx *context) testCProg(p *prog.Prog, duration time.Duration, opts csource } func (ctx *context) returnInstance(inst *reproInstance) { - ctx.bootRequests <- inst.index inst.execProg.Close() + ctx.bootRequests <- inst.index } func (ctx *context) reproLogf(level int, format string, args ...interface{}) { @@ -660,27 +660,19 @@ func (ctx *context) createInstances(cfg *mgrconfig.Config, vmPool *vm.Pool) { go func() { defer wg.Done() - var inst *instance.ExecProgInstance - maxTry := 3 - for try := 0; try < maxTry; try++ { + for try := 0; ; try++ { select { case <-vm.Shutdown: - try = maxTry - continue + return default: } - var err error - inst, err = instance.CreateExecProgInstance(vmPool, vmIndex, cfg, + inst, err := instance.CreateExecProgInstance(vmPool, vmIndex, cfg, ctx.reporter, &instance.OptionalConfig{Logf: ctx.reproLogf}) if err != nil { - ctx.reproLogf(0, "failed to init instance: %v, attempt %d/%d", - err, try+1, maxTry) + ctx.reproLogf(0, "failed to boot instance (try %v): %v", try+1, err) time.Sleep(10 * time.Second) continue } - break - } - if inst != nil { ctx.instances <- &reproInstance{execProg: inst, index: vmIndex} } }() -- cgit mrf-deployment