Skip to content

Commit

Permalink
Merge pull request #17757 from fuweid/should-fatal-if-panic
Browse files Browse the repository at this point in the history
storage/backend: fatal if there is panic during defrag
  • Loading branch information
serathius authored Nov 22, 2024
2 parents b1aa164 + c438fcb commit f77fa90
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/storage/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,16 @@ func (b *backend) defrag() error {
)
}

defer func() {
// NOTE: We should exit as soon as possible because that tx
// might be closed. The inflight request might use invalid
// tx and then panic as well. The real panic reason might be
// shadowed by new panic. So, we should fatal here with lock.
if rerr := recover(); rerr != nil {
b.lg.Fatal("unexpected panic during defrag", zap.Any("panic", rerr))
}
}()

// Commit/stop and then reset current transactions (including the readTx)
b.batchTx.unsafeCommit(true)
b.batchTx.tx = nil
Expand Down

0 comments on commit f77fa90

Please sign in to comment.