Skip to content

Commit

Permalink
Slightly improve logging (#152)
Browse files Browse the repository at this point in the history
* Slightly improve logging

* Style fix

* Style fix

* Add option to getLocalNodeState

* Remove the line
  • Loading branch information
noname0443 authored Jan 10, 2025
1 parent 3eeb942 commit 259919e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2202,8 +2202,10 @@ func (app *App) getLocalDaemonState() (*DaemonState, error) {
func (app *App) getClusterStateFromDB() map[string]*NodeState {
hosts := app.cluster.AllNodeHosts()
getter := func(host string) (*NodeState, error) {
if host == app.cluster.Local().Host() {
return app.getLocalNodeState(), nil
}
ns := app.getNodeState(host)
ns.ShowOnlyGTIDDiff = app.config.ShowOnlyGTIDDiff
return ns, nil
}
clusterState, _ := getNodeStatesInParallel(hosts, getter, app.logger)
Expand Down
7 changes: 7 additions & 0 deletions internal/app/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ func (ns *NodeState) String() string {
cr = "no"
}
}

// NodeState of replica doesn't know master gtid and always writes "master state not defined" when we calculate gtid diff
if ns.ShowOnlyGTIDDiff && ns.MasterState == nil {
return fmt.Sprintf("<ping=%s repl=%s sync=%s ro=%v offline=%v lag=%.02f du=%s cr=%s>",
ping, repl, sync, ns.IsReadOnly, ns.IsOffline, lag, du, cr)
}

return fmt.Sprintf("<ping=%s repl=%s sync=%s ro=%v offline=%v lag=%.02f du=%s cr=%s gtid=%s>",
ping, repl, sync, ns.IsReadOnly, ns.IsOffline, lag, du, cr, gtid)
}
Expand Down

0 comments on commit 259919e

Please sign in to comment.