Skip to content

Commit

Permalink
mvcc/backend: exit on racey after-stop commit call
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Oct 20, 2016
1 parent eff98b7 commit bbb28fb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mvcc/backend/batch_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type batchTx struct {
tx *bolt.Tx
backend *backend
pending int
stopped bool
}

func newBatchTx(backend *backend) *batchTx {
Expand Down Expand Up @@ -145,6 +146,7 @@ func (t *batchTx) CommitAndStop() {
t.Lock()
defer t.Unlock()
t.commit(true)
t.stopped = true
}

func (t *batchTx) Unlock() {
Expand All @@ -156,6 +158,10 @@ func (t *batchTx) Unlock() {
}

func (t *batchTx) commit(stop bool) {
if t.stopped {
return
}

var err error
// commit the last tx
if t.tx != nil {
Expand Down

0 comments on commit bbb28fb

Please sign in to comment.