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

improve the backward compatibility of “SHOW SLAVE HOSTS“ command #5017

Closed
duanhuichao opened this issue Mar 25, 2022 · 4 comments · Fixed by #7372
Closed

improve the backward compatibility of “SHOW SLAVE HOSTS“ command #5017

duanhuichao opened this issue Mar 25, 2022 · 4 comments · Fixed by #7372
Assignees
Labels
area/dm Issues or PRs related to DM. type/feature Issues about a new feature

Comments

@duanhuichao
Copy link

What did you do?

With the version upgrade, on the new version of MySQL Cluster, the query results of many system commands will display some new columns. These new columns show new features or information of MySQL.

In general, it is recommended to provide backward compatibility of system commands (e.g., show xxx) rather than hard-coded return value format (i.e., limiting the number of returned columns).

For DM, there are some commands that are difficult to backward-compatible:
(1) SHOW MASTER STATUS
(2) SHOW SLAVE HOSTS
(3) SHOW BINARY LOGS

These commands limit the return format by limiting the number of columns returned:

rows, err := db.QueryContext(ctx, `SHOW SLAVE HOSTS`)
rowColumns, err := rows.Columns()
if len(rowColumns) == 5 {
	err = rows.Scan(&serverID, &host, &port, &masterID, &slaveUUID)
} else {
	err = rows.Scan(&serverID, &host, &port, &masterID)
}

What did you expect to see?

Through the reflection mechanism, we only take the value of the required corresponding column and do not limit the number of returned columns.

import (
"reflect"
)

see:
https://stackoverflow.com/questions/21986780/is-it-possible-to-retrieve-a-column-value-by-name-using-golang-database-sql

What did you see instead?

For the above system commands, when the number of columns returned by MySQL changes, DM cannot work.

Versions of the cluster

any versions

current status of DM cluster (execute query-status <task-name> in dmctl)

No response

@duanhuichao duanhuichao added area/dm Issues or PRs related to DM. type/bug The issue is confirmed as a bug. labels Mar 25, 2022
duanhuichao pushed a commit to duanhuichao/tiflow that referenced this issue Mar 25, 2022
Problem:
With the version upgrade, on the new version of MySQL Cluster,
the query results of many system commands will display some new
columns. These new columns show new features or information of MySQL.

In general, it is recommended to provide backward compatibility of
system commands (e.g., show xxx) rather than hard-coded return value
format (i.e., limiting the number of returned columns).

For DM, there are some commands that are difficult to backward-compatible:
(1) SHOW MASTER STATUS
(2) SHOW SLAVE HOSTS
(3) SHOW BINARY LOGS

Fix:
Through the reflection mechanism, we only take the value of the required
corresponding column and do not limit the number of returned columns.
This patch removes the limit on the number of columns returned by the
'show slave hosts' command.

ref pingcap#2017
duanhuichao pushed a commit to duanhuichao/tiflow that referenced this issue Mar 25, 2022
Problem:
With the version upgrade, on the new version of MySQL Cluster,
the query results of many system commands will display some new
columns. These new columns show new features or information of MySQL.

In general, it is recommended to provide backward compatibility of
system commands (e.g., show xxx) rather than hard-coded return value
format (i.e., limiting the number of returned columns).

For DM, there are some commands that are difficult to backward-compatible:
(1) SHOW MASTER STATUS
(2) SHOW SLAVE HOSTS
(3) SHOW BINARY LOGS

Fix:
Through the reflection mechanism, we only take the value of the required
corresponding column and do not limit the number of returned columns.
This patch removes the limit on the number of columns returned by the
'show slave hosts' command.

ref pingcap#5017
@lance6716 lance6716 added type/feature Issues about a new feature and removed type/bug The issue is confirmed as a bug. labels Mar 31, 2022
@lance6716
Copy link
Contributor

Hi, which version of MySQL addes new columns? And please address comment in your PR

@ryangao0513
Copy link

Hello,I encountered the same problem in txsql 8.0.22 patch 20210330

@lance6716
Copy link
Contributor

happens again https://asktug.com/t/topic/813202

@lance6716
Copy link
Contributor

/assign @lyzx2001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dm Issues or PRs related to DM. type/feature Issues about a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants