aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-01-08 11:36:44 +0100
committerAlexander Potapenko <glider@google.com>2024-01-08 11:10:05 +0000
commit4c0fd4bb60ad179a6cf6be0edf416b2fca287b40 (patch)
tree2ced007d0799f9f8a0b5b00eba8c1992205db9f1
parentd0304e9cb9f633eb4de1ecbb4e7328ae745198a8 (diff)
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.
-rw-r--r--pkg/repro/repro.go18
1 files changed, 5 insertions, 13 deletions
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}
}
}()