|
|
@@ -308,7 +308,16 @@ func (t *batchTxBuffered) unsafeCommit(stop bool) {
|
|
|
if t.backend.readTx.tx != nil {
|
|
|
// wait all store read transactions using the current boltdb tx to finish,
|
|
|
// then close the boltdb tx
|
|
|
- go waitAndRollback(t.backend.readTx.tx, t.backend.readTx.txWg, t.backend.lg)
|
|
|
+ go func(tx *bolt.Tx, wg *sync.WaitGroup) {
|
|
|
+ wg.Wait()
|
|
|
+ if err := tx.Rollback(); err != nil {
|
|
|
+ if t.backend.lg != nil {
|
|
|
+ t.backend.lg.Fatal("failed to rollback tx", zap.Error(err))
|
|
|
+ } else {
|
|
|
+ plog.Fatalf("cannot rollback tx (%s)", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(t.backend.readTx.tx, t.backend.readTx.txWg)
|
|
|
t.backend.readTx.reset()
|
|
|
}
|
|
|
|
|
|
@@ -319,17 +328,6 @@ func (t *batchTxBuffered) unsafeCommit(stop bool) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func waitAndRollback(tx *bolt.Tx, wg *sync.WaitGroup, lg *zap.Logger) {
|
|
|
- wg.Wait()
|
|
|
- if err := tx.Rollback(); err != nil {
|
|
|
- if lg != nil {
|
|
|
- lg.Fatal("failed to rollback tx", zap.Error(err))
|
|
|
- } else {
|
|
|
- plog.Fatalf("cannot rollback tx (%s)", err)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func (t *batchTxBuffered) UnsafePut(bucketName []byte, key []byte, value []byte) {
|
|
|
t.batchTx.UnsafePut(bucketName, key, value)
|
|
|
t.buf.put(bucketName, key, value)
|