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

mysqld: check for correct return value from WAIT_FOR_EXECUTED_GTID_SET #14739

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (mysqld *Mysqld) WaitSourcePos(ctx context.Context, targetPos replication.P
if result.IsNull() {
return fmt.Errorf("%v(%v) failed: replication is probably stopped", waitCommandName, query)
}
if result.ToString() == "-1" {
if result.ToString() == "1" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should invert the check here and validate success.

For any functions that return C style integer arguments where one value specifically indicates success, we should always check against that value. I’ve see trying to check against failure values to cause problems too many times.

So either here do a != “0” or switch the return and fallback and do == “0”.

Copy link
Contributor

@mattlord mattlord Dec 9, 2023

Choose a reason for hiding this comment

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

Yeah, this way would work with 8.0 and 8.2 (and MariaDB). 0 is success, non-zero value is failure. And I think that we should add a const for it so that it's more obvious.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good points. I'll push a change.

Copy link
Member Author

Choose a reason for hiding this comment

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

See later comments from Rohit.

return fmt.Errorf("timed out waiting for position %v", targetPos)
}
return nil
Expand Down
Loading