Skip to content

Commit

Permalink
address the comment
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Oct 17, 2022
1 parent 8e18727 commit 3f5e02d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/core/basic_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,14 @@ func (bc *BasicCluster) GetStoreRegions(storeID uint64) []*RegionInfo {
// GetLeaderStoreByRegionID returns the leader store of the given region.
func (bc *BasicCluster) GetLeaderStoreByRegionID(regionID uint64) *StoreInfo {
bc.Regions.mu.RLock()
bc.Stores.mu.RLock()
defer bc.Stores.mu.RUnlock()
defer bc.Regions.mu.RUnlock()
region := bc.Regions.GetRegion(regionID)
if region == nil || region.GetLeader() == nil {
return nil
}
bc.Regions.mu.RUnlock()

bc.Stores.mu.RLock()
defer bc.Stores.mu.RUnlock()
return bc.Stores.GetStore(region.GetLeader().GetStoreId())
}

Expand Down

0 comments on commit 3f5e02d

Please sign in to comment.