From c1e2c9826fdc834504bf5de046921b87aa1a989d Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 5 Dec 2021 17:26:03 +0100 Subject: [PATCH] trace: hint debug env var in error when crashing due to active child tasks refs https://github.com/zrepl/zrepl/issues/542 --- daemon/logging/trace/trace.go | 2 +- daemon/logging/trace/trace_debug.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/logging/trace/trace.go b/daemon/logging/trace/trace.go index 8421800..08caea2 100644 --- a/daemon/logging/trace/trace.go +++ b/daemon/logging/trace/trace.go @@ -246,7 +246,7 @@ func WithTask(ctx context.Context, taskName string) (context.Context, DoneFunc) // the debugString can be quite long and panic won't print it completely fmt.Fprintf(os.Stderr, "going to panic due to activeChildTasks:\n%s\n", this.debugString()) } - panic(errors.WithMessagef(ErrTaskStillHasActiveChildTasks, "end task: %v active child tasks\n", this.activeChildTasks)) + panic(errors.WithMessagef(ErrTaskStillHasActiveChildTasks, "end task: %v active child tasks (run daemon with env var %s=1 for more details)\n", this.activeChildTasks, debugEnabledEnvVar)) } // support idempotent task ends diff --git a/daemon/logging/trace/trace_debug.go b/daemon/logging/trace/trace_debug.go index 93ca6e7..c12f80f 100644 --- a/daemon/logging/trace/trace_debug.go +++ b/daemon/logging/trace/trace_debug.go @@ -7,7 +7,9 @@ import ( "github.com/zrepl/zrepl/util/envconst" ) -var debugEnabled = envconst.Bool("ZREPL_TRACE_DEBUG_ENABLED", false) +const debugEnabledEnvVar = "ZREPL_TRACE_DEBUG_ENABLED" + +var debugEnabled = envconst.Bool(debugEnabledEnvVar, false) func debug(format string, args ...interface{}) { if !debugEnabled {