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 logging by omitting the host and port in SetReadOnly #13470

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions go/vt/mysqlctl/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ func (mysqld *Mysqld) SetReadOnly(on bool) error {
case true:
newState = "ReadOnly"
}
log.Infof("SetReadOnly setting connection setting of %s:%d to : %s",
mysqld.dbcfgs.Host, mysqld.dbcfgs.Port, newState)
params, _ := mysqld.dbcfgs.DbaWithDB().MysqlParams()
log.Infof("SetReadOnly setting connection setting of %s:%d, socket:%s to : %s",
params.Host, params.Port, params.UnixSocket, newState)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably check for errors here though as params might end up being nil leading to a panic on line 262

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Also good to get into the habit of using net.JoinHostPort().

Copy link
Member

@deepthi deepthi Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's useful to print the socket file path. From a debugging perspective we want to know which tablet alias this is operating on, not the socket file.
So my proposal is:

  • only log this if host/port are set, meaning external tablet mode
  • ensure that we log this using tablet alias somewhere in the call stack. That is information that is available higher up in the call stack, but not in this function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting connection setting is also misleading. ReadOnly is being set globally not on the connection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing with @deepthi offline, we agreed that since this is a vttablet log, the host port/socket that it is connected to, is not really interesting, because we only have 1 MySQL instance it is going to be connected to, so it going to run this query on that only. I have changed the log message and removed the host and port from it entirely.


query := "SET GLOBAL read_only = "
if on {
Expand Down