From 684ebf092847dacfe94c37e85c6474535619484e Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 16 Apr 2021 15:55:05 -0400 Subject: [PATCH] Don't cut off stack traces at 32MB. (#11364) --- changelog/11364.txt | 3 +++ command/server.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelog/11364.txt diff --git a/changelog/11364.txt b/changelog/11364.txt new file mode 100644 index 000000000..64fae590a --- /dev/null +++ b/changelog/11364.txt @@ -0,0 +1,3 @@ +```release-note:improvement +core: allow arbitrary length stack traces upon receiving SIGUSR2 (was 32MB) +``` diff --git a/command/server.go b/command/server.go index 1a5fc8240..974c914f9 100644 --- a/command/server.go +++ b/command/server.go @@ -14,6 +14,7 @@ import ( "os" "path/filepath" "runtime" + "runtime/pprof" "sort" "strconv" "strings" @@ -1969,9 +1970,8 @@ CLUSTER_SYNTHESIS_COMPLETE: } case <-c.SigUSR2Ch: - buf := make([]byte, 32*1024*1024) - n := runtime.Stack(buf[:], true) - c.logger.Info("goroutine trace", "stack", string(buf[:n])) + logWriter := c.logger.StandardWriter(&hclog.StandardLoggerOptions{}) + pprof.Lookup("goroutine").WriteTo(logWriter, 2) } }