From fb12a4e412fee79c8c59277f7e49d5cca5ed901f Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 22 May 2015 13:58:26 -0700 Subject: [PATCH] storage: fix a deadlock in batch tx --- storage/backend/batch_tx.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/backend/batch_tx.go b/storage/backend/batch_tx.go index 5df76f22e..ca8cc4532 100644 --- a/storage/backend/batch_tx.go +++ b/storage/backend/batch_tx.go @@ -43,7 +43,7 @@ func (t *batchTx) UnsafePut(bucketName []byte, key []byte, value []byte) { } t.pending++ if t.pending > t.backend.batchLimit { - t.Commit() + t.commit() t.pending = 0 } } @@ -85,7 +85,7 @@ func (t *batchTx) UnsafeDelete(bucketName []byte, key []byte) { } t.pending++ if t.pending > t.backend.batchLimit { - t.Commit() + t.commit() t.pending = 0 } } @@ -94,7 +94,10 @@ func (t *batchTx) UnsafeDelete(bucketName []byte, key []byte) { func (t *batchTx) Commit() { t.Lock() defer t.Unlock() + t.commit() +} +func (t *batchTx) commit() { var err error // commit the last tx if t.tx != nil {