Skip to content

Commit

Permalink
tso: put finishSplitKeyspaceGroup into the critical section (#6331)
Browse files Browse the repository at this point in the history
ref #6232

Put `finishSplitKeyspaceGroup` into the critical section.

Signed-off-by: JmPotato <[email protected]>

Co-authored-by: Ti Chi Robot <[email protected]>
  • Loading branch information
JmPotato and ti-chi-bot authored Apr 18, 2023
1 parent 66228ca commit e75eef1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/tso/keyspace_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,16 @@ func (kgm *KeyspaceGroupManager) checkTSOSplit(

const keyspaceGroupsAPIPrefix = "/pd/api/v2/tso/keyspace-groups"

// Put the code below into the critical section to prevent from sending too many HTTP requests.
func (kgm *KeyspaceGroupManager) finishSplitKeyspaceGroup(id uint32) error {
kgm.Lock()
defer kgm.Unlock()
// Check if the keyspace group is in split state.
splitGroup := kgm.kgs[id]
if !splitGroup.IsSplitTarget() {
return nil
}
// Check if the HTTP client is initialized.
if kgm.httpClient == nil {
return nil
}
Expand All @@ -832,5 +841,8 @@ func (kgm *KeyspaceGroupManager) finishSplitKeyspaceGroup(id uint32) error {
zap.Int("status-code", statusCode))
return errs.ErrSendRequest.FastGenByArgs()
}
// Pre-update the split keyspace group split state in memory.
splitGroup.SplitState = nil
kgm.kgs[id] = splitGroup
return nil
}

0 comments on commit e75eef1

Please sign in to comment.