Dump stack for stuck start and stuck watchdog

The meaning for skipDump was reversed, but not all callers
were updated. Change the meaning once again to forceDump, so
that the period between stack dump is respected from all
callers.

PiperOrigin-RevId: 308674373
This commit is contained in:
Fabricio Voznika
2020-04-27 12:30:49 -07:00
committed by gVisor bot
parent 55f0c3316a
commit 003e79a6d1
+11 -9
View File
@@ -255,7 +255,7 @@ func (w *Watchdog) runTurn() {
case <-done:
case <-time.After(w.TaskTimeout):
// Report if the watchdog is not making progress.
// No one is wathching the watchdog watcher though.
// No one is watching the watchdog watcher though.
w.reportStuckWatchdog()
<-done
}
@@ -317,10 +317,8 @@ func (w *Watchdog) report(offenders map[*kernel.Task]*offender, newTaskFound boo
buf.WriteString("Search for '(*Task).run(0x..., 0x<tid>)' in the stack dump to find the offending goroutine")
// Dump stack only if a new task is detected or if it sometime has
// passed since the last time a stack dump was generated.
showStack := newTaskFound || time.Since(w.lastStackDump) >= stackDumpSameTaskPeriod
w.doAction(w.TaskTimeoutAction, showStack, &buf)
// Force stack dump only if a new task is detected.
w.doAction(w.TaskTimeoutAction, newTaskFound, &buf)
}
func (w *Watchdog) reportStuckWatchdog() {
@@ -329,12 +327,15 @@ func (w *Watchdog) reportStuckWatchdog() {
w.doAction(w.TaskTimeoutAction, false, &buf)
}
// doAction will take the given action. If the action is LogWarning and
// showStack is false, then the stack printing will be skipped.
func (w *Watchdog) doAction(action Action, showStack bool, msg *bytes.Buffer) {
// doAction will take the given action. If the action is LogWarning, the stack
// is not always dumpped to the log to prevent log flooding. "forceStack"
// guarantees that the stack will be dumped regarless.
func (w *Watchdog) doAction(action Action, forceStack bool, msg *bytes.Buffer) {
switch action {
case LogWarning:
if !showStack {
// Dump stack only if forced or sometime has passed since the last time a
// stack dump was generated.
if !forceStack && time.Since(w.lastStackDump) < stackDumpSameTaskPeriod {
msg.WriteString("\n...[stack dump skipped]...")
log.Warningf(msg.String())
return
@@ -359,6 +360,7 @@ func (w *Watchdog) doAction(action Action, showStack bool, msg *bytes.Buffer) {
case <-time.After(1 * time.Second):
}
panic(fmt.Sprintf("%s\nStack for running G's are skipped while panicking.", msg.String()))
default:
panic(fmt.Sprintf("Unknown watchdog action %v", action))