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 TaskID transaction option in store/tikv #24407

Merged
merged 8 commits into from
May 10, 2021
2 changes: 2 additions & 0 deletions store/driver/txn/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func (s *tikvSnapshot) SetOption(opt int, val interface{}) {
s.KVSnapshot.SetNotFillCache(val.(bool))
case tikvstore.SnapshotTS:
s.KVSnapshot.SetSnapshotTS(val.(uint64))
case tikvstore.TaskID:
s.KVSnapshot.SetTaskID(val.(uint64))
default:
s.KVSnapshot.SetOption(opt, val)
}
Expand Down
2 changes: 2 additions & 0 deletions store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.SetPessimistic(val.(bool))
case tikvstore.SnapshotTS:
txn.KVTxn.GetSnapshot().SetSnapshotTS(val.(uint64))
case tikvstore.TaskID:
txn.KVTxn.GetSnapshot().SetTaskID(val.(uint64))
case tikvstore.InfoSchema:
txn.SetSchemaVer(val.(tikv.SchemaVer))
case tikvstore.CommitHook:
Expand Down
12 changes: 8 additions & 4 deletions store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) {
s.mu.Lock()
s.mu.replicaRead = val.(kv.ReplicaReadType)
s.mu.Unlock()
case kv.TaskID:
s.mu.Lock()
s.mu.taskID = val.(uint64)
s.mu.Unlock()
case kv.CollectRuntimeStats:
s.mu.Lock()
s.mu.stats = val.(*SnapshotRuntimeStats)
Expand Down Expand Up @@ -625,6 +621,14 @@ func (s *KVSnapshot) SetPriority(pri Priority) {
s.priority = pri
}

// SetTaskID marks current task's unique ID to allow TiKV to schedule
// tasks more fairly.
func (s *KVSnapshot) SetTaskID(id uint64) {
s.mu.Lock()
defer s.mu.Unlock()
s.mu.taskID = id
}

// SnapCacheHitCount gets the snapshot cache hit count. Only for test.
func (s *KVSnapshot) SnapCacheHitCount() int {
return int(atomic.LoadInt64(&s.mu.hitCnt))
Expand Down