v1.5.1 增强程序稳定性
This commit is contained in:
@@ -4,10 +4,13 @@ package kvstore
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cockroachdb/pebble"
|
||||
)
|
||||
|
||||
var commitBatch = func(batch *pebble.Batch, opt *pebble.WriteOptions) error {
|
||||
return batch.Commit(opt)
|
||||
}
|
||||
|
||||
type Tx[T any] struct {
|
||||
table *Table[T]
|
||||
readOnly bool
|
||||
@@ -129,12 +132,9 @@ func (this *Tx[T]) commit(opt *pebble.WriteOptions) (err error) {
|
||||
defer func() {
|
||||
var panicErr = recover()
|
||||
if panicErr != nil {
|
||||
resultErr, ok := panicErr.(error)
|
||||
if ok {
|
||||
err = fmt.Errorf("commit batch failed: %w", resultErr)
|
||||
}
|
||||
err = wrapRecoveredPanic("commit batch failed", panicErr)
|
||||
}
|
||||
}()
|
||||
|
||||
return this.batch.Commit(opt)
|
||||
return commitBatch(this.batch, opt)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user