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

*: fix ScheduleConfig data race #1307

Merged
merged 3 commits into from Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/cluster.go
Expand Up @@ -495,7 +495,7 @@ func (c *RaftCluster) SetStoreWeight(storeID uint64, leader, region float64) err

func (c *RaftCluster) checkStores() {
var offlineStores []*metapb.Store
var upStoreCount uint64
var upStoreCount int

cluster := c.cachedCluster

Expand Down Expand Up @@ -524,7 +524,7 @@ func (c *RaftCluster) checkStores() {
return
}

if upStoreCount < c.s.GetConfig().Replication.MaxReplicas {
if upStoreCount < cluster.GetMaxReplicas() {
for _, offlineStore := range offlineStores {
log.Warnf("store %v may not turn into Tombstone, there are no extra up node has enough space to accommodate the extra replica", offlineStore)
}
Expand Down
3 changes: 2 additions & 1 deletion server/coordinator.go
Expand Up @@ -189,7 +189,7 @@ func (c *coordinator) run() {
log.Info("coordinator: Run scheduler")

k := 0
scheduleCfg := c.cluster.opt.load()
scheduleCfg := c.cluster.opt.load().clone()
for _, schedulerCfg := range scheduleCfg.Schedulers {
if schedulerCfg.Disable {
scheduleCfg.Schedulers[k] = schedulerCfg
Expand All @@ -216,6 +216,7 @@ func (c *coordinator) run() {

// remove invalid scheduler config and persist
scheduleCfg.Schedulers = scheduleCfg.Schedulers[:k]
c.cluster.opt.store(scheduleCfg)
if err := c.cluster.opt.persist(c.cluster.kv); err != nil {
log.Errorf("can't persist schedule config: %v", err)
}
Expand Down