mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3703 from xiang90/bolt
storage/backend: avoid creating new bolt.tx during a batchTx
This commit is contained in:
commit
776e9fb7be
@ -64,10 +64,6 @@ func (t *batchTx) UnsafePut(bucketName []byte, key []byte, value []byte) {
|
||||
log.Fatalf("storage: cannot put key into bucket (%v)", err)
|
||||
}
|
||||
t.pending++
|
||||
if t.pending >= t.backend.batchLimit {
|
||||
t.commit(false)
|
||||
t.pending = 0
|
||||
}
|
||||
}
|
||||
|
||||
// before calling unsafeRange, the caller MUST hold the lock on tx.
|
||||
@ -108,10 +104,6 @@ func (t *batchTx) UnsafeDelete(bucketName []byte, key []byte) {
|
||||
log.Fatalf("storage: cannot delete key from bucket (%v)", err)
|
||||
}
|
||||
t.pending++
|
||||
if t.pending >= t.backend.batchLimit {
|
||||
t.commit(false)
|
||||
t.pending = 0
|
||||
}
|
||||
}
|
||||
|
||||
// Commit commits a previous tx and begins a new writable one.
|
||||
@ -128,6 +120,14 @@ func (t *batchTx) CommitAndStop() {
|
||||
t.commit(true)
|
||||
}
|
||||
|
||||
func (t *batchTx) Unlock() {
|
||||
if t.pending >= t.backend.batchLimit {
|
||||
t.commit(false)
|
||||
t.pending = 0
|
||||
}
|
||||
t.Mutex.Unlock()
|
||||
}
|
||||
|
||||
func (t *batchTx) commit(stop bool) {
|
||||
var err error
|
||||
// commit the last tx
|
||||
|
Loading…
x
Reference in New Issue
Block a user