mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
storage: fix a deadlock in batch tx
This commit is contained in:
parent
93ecf36855
commit
fb12a4e412
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user