Skip to content

Commit 30b430f

Browse files
rleungxHunDunDMti-chi-bot
authored
*: fix the data race problem (#3603)
* fix the data race problem Signed-off-by: Ryan Leung <rleungx@gmail.com> * address the comment Signed-off-by: Ryan Leung <rleungx@gmail.com> Co-authored-by: 混沌DM <hundundm@gmail.com> Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
1 parent ce22dbb commit 30b430f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

server/config/persist_options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,11 @@ func (o *PersistOptions) GetHotRegionCacheHitsThreshold() int {
495495
return int(o.GetScheduleConfig().HotRegionCacheHitsThreshold)
496496
}
497497

498+
// GetStoresLimit gets the stores' limit.
499+
func (o *PersistOptions) GetStoresLimit() map[uint64]StoreLimitConfig {
500+
return o.GetScheduleConfig().StoreLimit
501+
}
502+
498503
// GetSchedulers gets the scheduler configurations.
499504
func (o *PersistOptions) GetSchedulers() SchedulerConfigs {
500505
return o.GetScheduleConfig().Schedulers

server/server.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,7 @@ func (s *Server) GetConfig() *config.Config {
785785

786786
// GetScheduleConfig gets the balance config information.
787787
func (s *Server) GetScheduleConfig() *config.ScheduleConfig {
788-
cfg := &config.ScheduleConfig{}
789-
*cfg = *s.persistOptions.GetScheduleConfig()
790-
return cfg
788+
return s.persistOptions.GetScheduleConfig().Clone()
791789
}
792790

793791
// SetScheduleConfig sets the balance config information.
@@ -815,9 +813,7 @@ func (s *Server) SetScheduleConfig(cfg config.ScheduleConfig) error {
815813

816814
// GetReplicationConfig get the replication config.
817815
func (s *Server) GetReplicationConfig() *config.ReplicationConfig {
818-
cfg := &config.ReplicationConfig{}
819-
*cfg = *s.persistOptions.GetReplicationConfig()
820-
return cfg
816+
return s.persistOptions.GetReplicationConfig().Clone()
821817
}
822818

823819
// SetReplicationConfig sets the replication config.
@@ -905,9 +901,7 @@ func (s *Server) SetReplicationConfig(cfg config.ReplicationConfig) error {
905901

906902
// GetPDServerConfig gets the balance config information.
907903
func (s *Server) GetPDServerConfig() *config.PDServerConfig {
908-
cfg := &config.PDServerConfig{}
909-
*cfg = *s.persistOptions.GetPDServerConfig()
910-
return cfg
904+
return s.persistOptions.GetPDServerConfig().Clone()
911905
}
912906

913907
// SetPDServerConfig sets the server config.

server/statistics/store_collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (s *storeStatistics) Collect() {
187187
placementStatusGauge.WithLabelValues(labelType, name).Set(float64(value))
188188
}
189189

190-
for storeID, limit := range s.opt.GetScheduleConfig().StoreLimit {
190+
for storeID, limit := range s.opt.GetStoresLimit() {
191191
id := strconv.FormatUint(storeID, 10)
192192
StoreLimitGauge.WithLabelValues(id, "add-peer").Set(limit.AddPeer)
193193
StoreLimitGauge.WithLabelValues(id, "remove-peer").Set(limit.RemovePeer)

0 commit comments

Comments
 (0)