Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao committed Sep 17, 2019
1 parent 4dd7dca commit 8f09776
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions store/mockstore/mocktikv/mvcc_leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ func (mvcc *MVCCLevelDB) Cleanup(key []byte, startTS, currentTS uint64) error {
if err != nil {
return err
}
// If current transaction's lock exist.
// If current transaction's lock exists.
if ok && dec.lock.startTS == startTS {

// If the lock has already outdated, clean up it.
Expand All @@ -960,22 +960,22 @@ func (mvcc *MVCCLevelDB) Cleanup(key []byte, startTS, currentTS uint64) error {
return mvcc.db.Write(batch, nil)
}

// Otherwise, return a locked error to with the TTL information.
// Otherwise, return a locked error with the TTL information.
return dec.lock.lockErr(key)
}

// If current transaction's lock not exist.
// If commit info of current transaction exist.
// If current transaction's lock does not exist.
// If the commit information of the current transaction exist.
c, ok, err := getTxnCommitInfo(iter, key, startTS)
if err != nil {
return errors.Trace(err)
}
if ok {
// If current transaction is already committed.
// If the current transaction has already committed.
if c.valueType != typeRollback {
return ErrAlreadyCommitted(c.commitTS)
}
// If current transaction is already rollback.
// If the current transaction has already rollbacked.
return nil
}
}
Expand Down Expand Up @@ -1133,7 +1133,6 @@ func (mvcc *MVCCLevelDB) TxnHeartBeat(key []byte, startTS uint64, adviseTTL uint
return lock.ttl, nil
}
}

return 0, errors.New("lock doesn't exist")
}

Expand Down
2 changes: 1 addition & 1 deletion store/tikv/lock_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (lr *LockResolver) ResolveLocks(bo *Backoffer, locks []*Lock) (msBeforeTxnE
if msBeforeLockExpired <= 0 {
// The txn is a pessimistic transaction, and it's primary lock will expire soon, but
// TxnHeartBeat could update the TTL, so we should not clean up the lock.
continue
break

This comment has been minimized.

Copy link
@coocood

coocood Sep 17, 2019

Member

I mean we don't need to check msBeforeLockExpired <= 0

}
if msBeforeTxnExpired == 0 || msBeforeLockExpired < msBeforeTxnExpired {
msBeforeTxnExpired = msBeforeLockExpired
Expand Down

0 comments on commit 8f09776

Please sign in to comment.