Skip to content

Commit

Permalink
store/tikv: fix ttl manager race (#12398)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood authored and sre-bot committed Sep 26, 2019
1 parent 5986c6c commit ebce1f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 0 additions & 8 deletions store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,6 @@ func (c *twoPhaseCommitter) prewriteSingleBatch(bo *Backoffer, batch batchKeys)
prewriteResp := resp.Resp.(*pb.PrewriteResponse)
keyErrs := prewriteResp.GetErrors()
if len(keyErrs) == 0 {
isPrimary := bytes.Equal(batch.keys[0], c.primary())
if isPrimary && c.isPessimistic {
c.ttlManager.run(c)
}
return nil
}
var locks []*Lock
Expand Down Expand Up @@ -712,10 +708,6 @@ func (c *twoPhaseCommitter) pessimisticLockSingleBatch(bo *Backoffer, batch batc
lockResp := resp.Resp.(*pb.PessimisticLockResponse)
keyErrs := lockResp.GetErrors()
if len(keyErrs) == 0 {
isPrimary := bytes.Equal(batch.keys[0], c.primary())
if isPrimary { // No need to check isPessimistic because this function is only called in that case.
c.ttlManager.run(c)
}
return nil
}
var locks []*Lock
Expand Down
3 changes: 3 additions & 0 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ func (txn *tikvTxn) LockKeys(ctx context.Context, forUpdateTS uint64, keysInput
}
return err
}
if assignedPrimaryKey {
txn.committer.ttlManager.run(txn.committer)
}
}
txn.mu.Lock()
txn.lockKeys = append(txn.lockKeys, keys...)
Expand Down

0 comments on commit ebce1f0

Please sign in to comment.