From d4528b74a25d0b8786382e9efd1a8b3547c46baf Mon Sep 17 00:00:00 2001 From: Yilin Chen Date: Thu, 15 Apr 2021 11:39:01 +0800 Subject: [PATCH] fix a failing unit test Signed-off-by: Yilin Chen --- store/driver/txn/txn_driver.go | 6 +++--- store/tikv/tests/2pc_test.go | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/store/driver/txn/txn_driver.go b/store/driver/txn/txn_driver.go index 157baeb280210..30567577b4549 100644 --- a/store/driver/txn/txn_driver.go +++ b/store/driver/txn/txn_driver.go @@ -32,7 +32,7 @@ type tikvTxn struct { // NewTiKVTxn returns a new Transaction. func NewTiKVTxn(txn *tikv.KVTxn) kv.Transaction { - txn.SetOption(tikvstore.KVFilter, kvFilter{}) + txn.SetOption(tikvstore.KVFilter, TiDBKVFilter{}) return &tikvTxn{txn, make(map[int64]*model.TableInfo)} } @@ -143,9 +143,9 @@ func (txn *tikvTxn) extractKeyExistsErr(key kv.Key) error { return extractKeyExistsErrFromIndex(key, value, tblInfo, indexID) } -type kvFilter struct{} +type TiDBKVFilter struct{} // IsUnnecessaryKeyValue defines which kinds of KV pairs from TiDB needn't be committed. -func (f kvFilter) IsUnnecessaryKeyValue(key, value []byte, flags tikvstore.KeyFlags) bool { +func (f TiDBKVFilter) IsUnnecessaryKeyValue(key, value []byte, flags tikvstore.KeyFlags) bool { return tablecodec.IsUntouchedIndexKValue(key, value) } diff --git a/store/tikv/tests/2pc_test.go b/store/tikv/tests/2pc_test.go index 42b2c0516d56e..0f7bf80028fc2 100644 --- a/store/tikv/tests/2pc_test.go +++ b/store/tikv/tests/2pc_test.go @@ -30,6 +30,7 @@ import ( "github.com/pingcap/kvproto/pkg/kvrpcpb" pb "github.com/pingcap/kvproto/pkg/kvrpcpb" tidbkv "github.com/pingcap/tidb/kv" + drivertxn "github.com/pingcap/tidb/store/driver/txn" "github.com/pingcap/tidb/store/mockstore/mocktikv" "github.com/pingcap/tidb/store/tikv" "github.com/pingcap/tidb/store/tikv/config" @@ -1032,6 +1033,7 @@ func (s *testCommitterSuite) TestResolvePessimisticLock(c *C) { noValueIndexKey := []byte("t00000001_i000000002") c.Assert(tablecodec.IsUntouchedIndexKValue(untouchedIndexKey, untouchedIndexValue), IsTrue) txn := s.begin(c) + txn.SetOption(kv.KVFilter, drivertxn.TiDBKVFilter{}) err := txn.Set(untouchedIndexKey, untouchedIndexValue) c.Assert(err, IsNil) lockCtx := &tidbkv.LockCtx{ForUpdateTS: txn.StartTS(), WaitStartTime: time.Now(), LockWaitTime: tidbkv.LockNoWait}