From 1dbdc3e85cb4353a6acf28cf774e307a90f01139 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Mon, 16 Dec 2019 19:41:55 +0800 Subject: [PATCH] mocktikv: add the missing ConflictCommitTS (#14064) --- store/mockstore/mocktikv/errors.go | 7 ++++--- store/mockstore/mocktikv/mvcc_leveldb.go | 7 ++++--- store/mockstore/mocktikv/rpc.go | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/store/mockstore/mocktikv/errors.go b/store/mockstore/mocktikv/errors.go index 82643730f0df3..e3a909a07f24f 100644 --- a/store/mockstore/mocktikv/errors.go +++ b/store/mockstore/mocktikv/errors.go @@ -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 { diff --git a/store/mockstore/mocktikv/mvcc_leveldb.go b/store/mockstore/mocktikv/mvcc_leveldb.go index 8e91689378a71..85ec7c522d07e 100644 --- a/store/mockstore/mocktikv/mvcc_leveldb.go +++ b/store/mockstore/mocktikv/mvcc_leveldb.go @@ -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, } } diff --git a/store/mockstore/mocktikv/rpc.go b/store/mockstore/mocktikv/rpc.go index 00eb09dc8fa4a..5f0e416c5c2ca 100644 --- a/store/mockstore/mocktikv/rpc.go +++ b/store/mockstore/mocktikv/rpc.go @@ -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, }, } }