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

store/tikv: remove use of KeyOnly transaction option in store/tikv #24334

Merged
merged 3 commits into from
Apr 29, 2021
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: 5 additions & 2 deletions store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) {
s.notFillCache = val.(bool)
case kv.SyncLog:
s.syncLog = val.(bool)
case kv.KeyOnly:
s.keyOnly = val.(bool)
case kv.SnapshotTS:
s.setSnapshotTS(val.(uint64))
case kv.ReplicaRead:
Expand Down Expand Up @@ -589,6 +587,11 @@ func (s *KVSnapshot) DelOption(opt int) {
}
}

// SetKeyOnly updates option to scan only keys.
disksing marked this conversation as resolved.
Show resolved Hide resolved
func (s *KVSnapshot) SetKeyOnly(b bool) {
s.keyOnly = b
}

// SnapCacheHitCount gets the snapshot cache hit count. Only for test.
func (s *KVSnapshot) SnapCacheHitCount() int {
return int(atomic.LoadInt64(&s.mu.hitCnt))
Expand Down
3 changes: 1 addition & 2 deletions store/tikv/tests/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/pingcap/kvproto/pkg/kvrpcpb"
tidbkv "github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/store/tikv"
"github.com/pingcap/tidb/store/tikv/kv"
"github.com/pingcap/tidb/store/tikv/oracle"
"github.com/pingcap/tidb/store/tikv/tikvrpc"
)
Expand Down Expand Up @@ -142,7 +141,7 @@ func (s *testLockSuite) TestScanLockResolveWithSeekKeyOnly(c *C) {

txn, err := s.store.Begin()
c.Assert(err, IsNil)
txn.SetOption(kv.KeyOnly, true)
txn.GetSnapshot().SetKeyOnly(true)
iter, err := txn.Iter([]byte("a"), nil)
c.Assert(err, IsNil)
for ch := byte('a'); ch <= byte('z'); ch++ {
Expand Down
4 changes: 2 additions & 2 deletions store/tikv/tests/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *testScanSuite) TestScan(c *C) {
check(c, scan, upperBound, false)

txn3 := s.beginTxn(c)
txn3.SetOption(kv.KeyOnly, true)
txn3.GetSnapshot().SetKeyOnly(true)
// Test scan without upper bound
scan, err = txn3.Iter(s.recordPrefix, nil)
c.Assert(err, IsNil)
Expand All @@ -157,7 +157,7 @@ func (s *testScanSuite) TestScan(c *C) {
check(c, scan, upperBound, true)

// Restore KeyOnly to false
txn3.SetOption(kv.KeyOnly, false)
txn3.GetSnapshot().SetKeyOnly(false)
scan, err = txn3.Iter(s.recordPrefix, nil)
c.Assert(err, IsNil)
check(c, scan, rowNum, true)
Expand Down