Skip to content

Commit

Permalink
mocktikv: add the missing ConflictCommitTS (#14064)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored and sre-bot committed Dec 16, 2019
1 parent 2c6f446 commit 1dbdc3e
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 @@ -70,9 +70,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 @@ -655,9 +655,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,
}
}

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 1dbdc3e

Please sign in to comment.