Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mocktikv: add the missing ConflictCommitTS #14064

Merged
merged 2 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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