Skip to content

Commit

Permalink
store/tikv: remove kvfilter option (#24303)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing committed Apr 28, 2021
1 parent c347c6c commit 83ebd6b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type tikvTxn struct {

// NewTiKVTxn returns a new Transaction.
func NewTiKVTxn(txn *tikv.KVTxn) kv.Transaction {
txn.SetOption(tikvstore.KVFilter, TiDBKVFilter{})
txn.SetKVFilter(TiDBKVFilter{})

entryLimit := atomic.LoadUint64(&kv.TxnEntrySizeLimit)
totalLimit := atomic.LoadUint64(&kv.TxnTotalSizeLimit)
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (c *twoPhaseCommitter) initKeysAndMutations() error {
sizeHint := txn.us.GetMemBuffer().Len()
c.mutations = newMemBufferMutations(sizeHint, memBuf)
c.isPessimistic = txn.IsPessimistic()
filter := txn.getKVFilter()
filter := txn.kvFilter

var err error
for it := memBuf.IterWithFlags(nil, nil); it.Valid(); err = it.Next() {
Expand Down
2 changes: 0 additions & 2 deletions store/tikv/kv/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ const (
IsStalenessReadOnly
// MatchStoreLabels indicates the labels the store should be matched
MatchStoreLabels
// KVFilter filters out the key-value pairs in the memBuf that is unnecessary to be committed
KVFilter
)

// Priority value for transaction priority.
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/tests/2pc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ func (s *testCommitterSuite) TestResolvePessimisticLock(c *C) {
untouchedIndexValue := []byte{0, 0, 0, 0, 0, 0, 0, 1, 49}
noValueIndexKey := []byte("t00000001_i000000002")
txn := s.begin(c)
txn.SetOption(kv.KVFilter, drivertxn.TiDBKVFilter{})
txn.SetKVFilter(drivertxn.TiDBKVFilter{})
err := txn.Set(untouchedIndexKey, untouchedIndexValue)
c.Assert(err, IsNil)
lockCtx := &kv.LockCtx{ForUpdateTS: txn.StartTS(), WaitStartTime: time.Now(), LockWaitTime: tikv.LockNoWait}
Expand Down
16 changes: 7 additions & 9 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ type KVTxn struct {
schemaAmender SchemaAmender
// commitCallback is called after current transaction gets committed
commitCallback func(info string, err error)

binlog BinlogExecutor
binlog BinlogExecutor
kvFilter KVFilter
}

func newTiKVTxn(store *KVStore, txnScope string) (*KVTxn, error) {
Expand Down Expand Up @@ -198,18 +198,16 @@ func (txn *KVTxn) DelOption(opt int) {
txn.us.DelOption(opt)
}

// SetKVFilter sets the filter to ignore key-values in memory buffer.
func (txn *KVTxn) SetKVFilter(filter KVFilter) {
txn.kvFilter = filter
}

// IsPessimistic returns true if it is pessimistic.
func (txn *KVTxn) IsPessimistic() bool {
return txn.us.GetOption(kv.Pessimistic) != nil
}

func (txn *KVTxn) getKVFilter() KVFilter {
if filter := txn.us.GetOption(kv.KVFilter); filter != nil {
return filter.(KVFilter)
}
return nil
}

// Commit commits the transaction operations to KV store.
func (txn *KVTxn) Commit(ctx context.Context) error {
if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
Expand Down

0 comments on commit 83ebd6b

Please sign in to comment.