Commit a257d501 authored by George Goldberg's avatar George Goldberg Committed by Christopher Speller

MM-12080: Added some extra logging to cluster leader changed. (#9475)

Purpose of this is to make in-field debugging of cluster leader issues
(particularly around duplicate job scheduling) easier to debug from
production server logs.
parent 760e2007
...@@ -244,6 +244,7 @@ func New(options ...Option) (outApp *App, outErr error) { ...@@ -244,6 +244,7 @@ func New(options ...Option) (outApp *App, outErr error) {
}) })
app.clusterLeaderListenerId = app.AddClusterLeaderChangedListener(func() { app.clusterLeaderListenerId = app.AddClusterLeaderChangedListener(func() {
mlog.Info("Cluster leader changed. Determining if job schedulers should be running:", mlog.Bool("isLeader", app.IsLeader()))
app.Jobs.Schedulers.HandleClusterLeaderChange(app.IsLeader()) app.Jobs.Schedulers.HandleClusterLeaderChange(app.IsLeader())
}) })
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
package app package app
import "github.com/mattermost/mattermost-server/model" import (
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
)
// Registers a given function to be called when the cluster leader may have changed. Returns a unique ID for the // Registers a given function to be called when the cluster leader may have changed. Returns a unique ID for the
// listener which can later be used to remove it. If clustering is not enabled in this build, the callback will never // listener which can later be used to remove it. If clustering is not enabled in this build, the callback will never
...@@ -20,6 +23,7 @@ func (a *App) RemoveClusterLeaderChangedListener(id string) { ...@@ -20,6 +23,7 @@ func (a *App) RemoveClusterLeaderChangedListener(id string) {
} }
func (a *App) InvokeClusterLeaderChangedListeners() { func (a *App) InvokeClusterLeaderChangedListeners() {
mlog.Info("Cluster leader changed. Invoking ClusterLeaderChanged listeners.")
a.Go(func() { a.Go(func() {
a.clusterLeaderListeners.Range(func(_, listener interface{}) bool { a.clusterLeaderListeners.Range(func(_, listener interface{}) bool {
listener.(func())() listener.(func())()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment