-
Notifications
You must be signed in to change notification settings - Fork 726
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
scheduler: add debug log #907
Conversation
server/schedulers/balance_leader.go
Outdated
@@ -74,6 +75,8 @@ func (l *balanceLeaderScheduler) Schedule(cluster schedule.Cluster, opInfluence | |||
|
|||
source := cluster.GetStore(region.Leader.GetStoreId()) | |||
target := cluster.GetStore(newLeader.GetStoreId()) | |||
log.Debugf("source store is %v", source) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please combine two logs into one, add scheduler name .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add [region xxx] xxx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but I think it's not necessary to add scheduler name, cause log will print file name
server/schedulers/utils.go
Outdated
@@ -39,6 +39,8 @@ func scheduleTransferLeader(cluster schedule.Cluster, schedulerName string, s sc | |||
|
|||
mostLeaderStore := s.SelectSource(cluster, stores, filters...) | |||
leastLeaderStore := s.SelectTarget(cluster, stores, filters...) | |||
log.Debugf("mostLeaderStore is %v", mostLeaderStore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
server/schedulers/utils.go
Outdated
@@ -63,7 +67,7 @@ func scheduleTransferLeader(cluster schedule.Cluster, schedulerName string, s sc | |||
region, peer = scheduleRemoveLeader(cluster, schedulerName, mostLeaderStore.GetId(), s) | |||
} | |||
} | |||
|
|||
log.Debugf("transfer leader select %v to be new leader for region %v", peer, region) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[region xxx] do ...
server/api/debug.go
Outdated
return | ||
} | ||
|
||
level := "info" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to set log level by string. If original level is "warning" or "error", we will not able to recover after debug.
server/schedule/filters.go
Outdated
@@ -31,6 +32,7 @@ type Filter interface { | |||
func FilterSource(opt Options, store *core.StoreInfo, filters []Filter) bool { | |||
for _, filter := range filters { | |||
if filter.FilterSource(opt, store) { | |||
log.Debugf("[filter %T] filtes store %v from source", filter, store) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filtes -> filters.
server/api/debug.go
Outdated
if debug { | ||
level = "debug" | ||
} | ||
h.svr.SetLogLevel(level) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry the data race here. Changing log level is not thread safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server reads cfg.Log only when initing logger, and setloglevel is not an operation with high frequency. Even if it causes write-write-conflict, it seems that it does not matter here.
please attach |
server/schedulers/balance_leader.go
Outdated
@@ -74,6 +75,7 @@ func (l *balanceLeaderScheduler) Schedule(cluster schedule.Cluster, opInfluence | |||
|
|||
source := cluster.GetStore(region.Leader.GetStoreId()) | |||
target := cluster.GetStore(newLeader.GetStoreId()) | |||
log.Debugf("source store is %v, target store is %v", source, target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log store id should be enough.
server/schedulers/balance_region.go
Outdated
@@ -117,6 +118,7 @@ func (s *balanceRegionScheduler) transferPeer(cluster schedule.Cluster, region * | |||
|
|||
target := cluster.GetStore(newPeer.GetStoreId()) | |||
avgScore := cluster.GetStoresAverageScore(core.RegionKind) | |||
log.Debugf("source store is %v, target store is %v", source, target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log store id should be enough.
@@ -31,6 +32,7 @@ type Filter interface { | |||
func FilterSource(opt Options, store *core.StoreInfo, filters []Filter) bool { | |||
for _, filter := range filters { | |||
if filter.FilterSource(opt, store) { | |||
log.Debugf("[filter %T] filters store %v from source", filter, store) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%T will output all the fields of the filter, is it ok here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it outputs like "*schedule.excludedFilter"
server/schedulers/balance_leader.go
Outdated
@@ -74,6 +75,7 @@ func (l *balanceLeaderScheduler) Schedule(cluster schedule.Cluster, opInfluence | |||
|
|||
source := cluster.GetStore(region.Leader.GetStoreId()) | |||
target := cluster.GetStore(newLeader.GetStoreId()) | |||
log.Debugf("source store id is %v, target store id is %v", source.GetId(), target.GetId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add region
server/schedulers/balance_region.go
Outdated
@@ -117,6 +118,7 @@ func (s *balanceRegionScheduler) transferPeer(cluster schedule.Cluster, region * | |||
|
|||
target := cluster.GetStore(newPeer.GetStoreId()) | |||
avgScore := cluster.GetStoresAverageScore(core.RegionKind) | |||
log.Debugf("source store id is %v, target store id is %v", source.GetId(), target.GetId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add region
server/schedulers/utils.go
Outdated
@@ -39,6 +39,7 @@ func scheduleTransferLeader(cluster schedule.Cluster, schedulerName string, s sc | |||
|
|||
mostLeaderStore := s.SelectSource(cluster, stores, filters...) | |||
leastLeaderStore := s.SelectTarget(cluster, stores, filters...) | |||
log.Debugf("[%v] mostLeaderStore is %v, leastLeaderStore is %v", schedulerName, mostLeaderStore, leastLeaderStore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[%s]
server/schedulers/utils.go
Outdated
if region == nil { | ||
log.Debugf("[%v] select no region", schedulerName) | ||
} else { | ||
log.Debugf("[region %v][%v] select %v to be new leader", schedulerName, region.GetId(), peer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the parameter does not correspond.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I mistake the order
server/schedulers/utils.go
Outdated
@@ -183,6 +190,7 @@ func shouldBalance(source, target *core.StoreInfo, avgScore float64, kind core.R | |||
sourceSizeDiff := (sourceScore - avgScore) * source.ResourceWeight(kind) | |||
targetSizeDiff := (avgScore - targetScore) * target.ResourceWeight(kind) | |||
|
|||
log.Debugf("size diff is %v and region size is %v", math.Min(sourceSizeDiff, targetSizeDiff), float64(region.ApproximateSize)*tolerantRatio) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
region size -> tolerable size?better to indicate region id.
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
this pr: