Skip to content

Commit 90a7ef3

Browse files
committed
add a stack trace to recovered panic
1 parent 25ec26d commit 90a7ef3

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

server/connection_handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func (h *ConnectionHandler) HandleConnection() {
140140
if HandlePanics {
141141
defer func() {
142142
if r := recover(); r != nil {
143+
// debug.Stack() here prints the stack trace of the original panic, not the lexical stack of this defer function
143144
logrus.Errorf("Listener recovered panic: %v: %s", r, string(debug.Stack()))
144145

145146
var eomErr error

server/doltgres_handler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"os"
2424
"regexp"
25+
"runtime/debug"
2526
"runtime/trace"
2627
"sync"
2728
"time"
@@ -626,7 +627,8 @@ func (h *DoltgresHandler) resultForDefaultIter(ctx *sql.Context, schema sql.Sche
626627
pan2err := func(err *error) {
627628
if HandlePanics {
628629
if recoveredPanic := recover(); recoveredPanic != nil {
629-
*err = goerrors.Join(*err, errors.Errorf("DoltgresHandler caught panic: %v", recoveredPanic))
630+
// debug.Stack() here prints the stack trace of the original panic, not the lexical stack of this defer function
631+
*err = goerrors.Join(*err, errors.Errorf("DoltgresHandler caught panic: %v: %s", recoveredPanic, debug.Stack()))
630632
}
631633
}
632634
}

0 commit comments

Comments
 (0)