Skip to content

Commit

Permalink
mocktikv: add the missing ConflictCommitTS (#14064) (#14080)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Dec 16, 2019
1 parent 13b945d commit b9ba3ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions store/mockstore/mocktikv/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ func (e ErrAlreadyCommitted) Error() string {

// ErrConflict is returned when the commitTS of key in the DB is greater than startTS.
type ErrConflict struct {
StartTS uint64
ConflictTS uint64
Key []byte
StartTS uint64
ConflictTS uint64
ConflictCommitTS uint64
Key []byte
}

func (e *ErrConflict) Error() string {
Expand Down
7 changes: 4 additions & 3 deletions store/mockstore/mocktikv/mvcc_leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,10 @@ func checkConflictValue(iter *Iterator, m *kvrpcpb.Mutation, startTS uint64) err
// Note that it's a write conflict here, even if the value is a rollback one.
if dec.value.commitTS >= startTS {
return &ErrConflict{
StartTS: startTS,
ConflictTS: dec.value.commitTS,
Key: m.Key,
StartTS: startTS,
ConflictTS: dec.value.startTS,
ConflictCommitTS: dec.value.commitTS,
Key: m.Key,
}
}
if m.Op == kvrpcpb.Op_PessimisticLock && m.Assertion == kvrpcpb.Assertion_NotExist {
Expand Down
7 changes: 4 additions & 3 deletions store/mockstore/mocktikv/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ func convertToKeyError(err error) *kvrpcpb.KeyError {
if writeConflict, ok := errors.Cause(err).(*ErrConflict); ok {
return &kvrpcpb.KeyError{
Conflict: &kvrpcpb.WriteConflict{
Key: writeConflict.Key,
ConflictTs: writeConflict.ConflictTS,
StartTs: writeConflict.StartTS,
Key: writeConflict.Key,
ConflictTs: writeConflict.ConflictTS,
ConflictCommitTs: writeConflict.ConflictCommitTS,
StartTs: writeConflict.StartTS,
},
}
}
Expand Down

0 comments on commit b9ba3ef

Please sign in to comment.