Merge pull request #16086 from cezarsa/full_stack_dump
Ensure goroutines dump is not truncated
This commit is contained in:
commit
48e15d83d2
1 changed files with 11 additions and 2 deletions
|
@ -57,8 +57,17 @@ func Trap(cleanup func()) {
|
||||||
|
|
||||||
// DumpStacks dumps the runtime stack.
|
// DumpStacks dumps the runtime stack.
|
||||||
func DumpStacks() {
|
func DumpStacks() {
|
||||||
buf := make([]byte, 16384)
|
var (
|
||||||
buf = buf[:runtime.Stack(buf, true)]
|
buf []byte
|
||||||
|
stackSize int
|
||||||
|
)
|
||||||
|
bufferLen := 16384
|
||||||
|
for stackSize == len(buf) {
|
||||||
|
buf = make([]byte, bufferLen)
|
||||||
|
stackSize = runtime.Stack(buf, true)
|
||||||
|
bufferLen *= 2
|
||||||
|
}
|
||||||
|
buf = buf[:stackSize]
|
||||||
// Note that if the daemon is started with a less-verbose log-level than "info" (the default), the goroutine
|
// Note that if the daemon is started with a less-verbose log-level than "info" (the default), the goroutine
|
||||||
// traces won't show up in the log.
|
// traces won't show up in the log.
|
||||||
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
|
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
|
||||||
|
|
Loading…
Reference in a new issue