Merge c8e050b7e0974081d9a03c1ea4ef541cb38d0585 into c86c93ca2951338115159dcdd20711603044e1f1

This commit is contained in:
Fu Wei 2024-09-25 22:30:01 -07:00 committed by GitHub
commit d235a463fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -477,6 +477,16 @@ func (b *backend) defrag() error {
b.readTx.Lock() b.readTx.Lock()
defer b.readTx.Unlock() defer b.readTx.Unlock()
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))
}
}()
b.batchTx.unsafeCommit(true) b.batchTx.unsafeCommit(true)
b.batchTx.tx = nil b.batchTx.tx = nil