Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

utils: don't panic when no row returned for SHOW MASTER STATUS #1733

Merged
merged 8 commits into from
Jun 15, 2021

Conversation

lance6716
Copy link
Collaborator

What problem does this PR solve?

close #1732

What is changed and how it works?

give an error with message, to maintain "When the returned error is nil, the gtid.Set must be not nil"

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

@lance6716 lance6716 added needs-cherry-pick-release-2.0 This PR should be cherry-picked to release-2.0. Remove this label after cherry-picked to release-2.0 needs-update-release-note This PR should be added into release notes. Remove this label once the release notes are updated and removed size/M labels May 28, 2021
@lance6716 lance6716 added this to the v2.0.4 milestone May 28, 2021
Copy link
Contributor

@lichunzhu lichunzhu left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment on lines +209 to +212
if len(rowColumns) == 5 {
err = rows.Scan(&binlogName, &pos, &nullPtr, &nullPtr, &gtidStr)
} else {
err = rows.Scan(&binlogName, &pos, &nullPtr, &nullPtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

if rows.Next() {
log.L().Warn("SHOW MASTER STATUS returns more than one row, will only use first row")
}

if rows.Err() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd better close rows before checking rows.Err().

@@ -201,26 +202,32 @@ func GetMasterStatus(ctx context.Context, db *sql.DB, flavor string) (gmysql.Pos
pos uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add show master status result from mariadb in comment ?

something like

		For MariaDB,SHOW MASTER STATUS:
		+--------------------+----------+--------------+------------------+
		| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
		+--------------------+----------+--------------+------------------+
		| mariadb-bin.000016 |      475 |              |                  |
		+--------------------+----------+--------------+------------------+
		SELECT @@global.gtid_binlog_pos;
		+--------------------------+
		| @@global.gtid_binlog_pos |
		+--------------------------+
		| 0-1-2                    |
		+--------------------------+

Copy link
Collaborator

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • GMHDBJD

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the status/LGT1 One reviewer already commented LGTM label Jun 10, 2021
@Ehco1996
Copy link
Contributor

LGTM

@lance6716 lance6716 added the require-LGT1 for small PR, LGT1 is enough label Jun 15, 2021
@lance6716
Copy link
Collaborator Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: e03ad76

@ti-chi-bot ti-chi-bot merged commit d706a25 into pingcap:master Jun 15, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #1774.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-cherry-pick-release-2.0 This PR should be cherry-picked to release-2.0. Remove this label after cherry-picked to release-2.0 needs-update-release-note This PR should be added into release notes. Remove this label once the release notes are updated require-LGT1 for small PR, LGT1 is enough size/M status/can-merge status/LGT1 One reviewer already commented LGTM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When SHOW MASTER STATUS returns no row and no error (PolarDB), DM-worker will panic
5 participants