Skip to content

Commit

Permalink
store/tikv: remove use of TaskID transaction option in store/tikv (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored May 10, 2021
1 parent b8cad01 commit c6c8265
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit c6c8265

Please sign in to comment.