Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Support Aliyun RDS #541
Support Aliyun RDS #541
Conversation
ilegal values. Add --aliyun-rds flag to avoid getting them.
|
Great,hope this PR could be merged into the trunk ASAP!:) |
|
I'm very sorry for the delay. I'll be looking into this in more depth shortly. |
|
Sorry for the delay, I'll be reviewing this shortly. |
|
@shlomi-noach Any progress ? |
|
Thank you for the PR! Few notes:
The entire block: if impliedKey, err := mysql.GetInstanceKey(this.db, this.migrationContext.AliyunRDS); err != nil {
return err
} else {
if this.migrationContext.AliyunRDS != true {
this.connectionConfig.ImpliedKey = impliedKey
}
}confuses me greatly. Can we not simplify it into: if !this.migrationContext.AliyunRDS {
if impliedKey, err := mysql.GetInstanceKey(this.db); err != nil {
return err
} else {
this.connectionConfig.ImpliedKey = impliedKey
}
}and so also get rid of the change to |
| instanceKey = &InstanceKey{} | ||
| err = db.QueryRow(`select @@global.hostname, @@global.port`).Scan(&instanceKey.Hostname, &instanceKey.Port) | ||
| if isAliyunRDS != true { |
shlomi-noach
Mar 27, 2018
Contributor
Please change to if !isAliyunRDS {
Please change to if !isAliyunRDS {
shlomi-noach
Mar 27, 2018
Contributor
Or also see my suggestion to replace the entire block.
Or also see my suggestion to replace the entire block.
| return err | ||
| } else { | ||
| this.connectionConfig.ImpliedKey = impliedKey | ||
| if this.migrationContext.AliyunRDS != true { |
shlomi-noach
Mar 27, 2018
Contributor
Please change to if !isAliyunRDS {
Please change to if !isAliyunRDS {
shlomi-noach
Mar 27, 2018
Contributor
Or also see my suggestion to replace the entire block.
Or also see my suggestion to replace the entire block.
| @@ -214,6 +215,8 @@ type ContextConfig struct { | |||
| } | |||
| } | |||
|
|
|||
| var Context *MigrationContext | |||
shlomi-noach
Mar 27, 2018
Contributor
I'd like to get rid of this global variable.
I'd like to get rid of this global variable.
zhangxiaojian
Mar 28, 2018
Author
Contributor
The global variable is used in base/utils.go ValidateConnection. I need to get the aliyunRDS flag to avoid get the port from database. If don't use the global variable, add a param ( migrationContext may be ) to the function? or any other suggestions ?
The global variable is used in base/utils.go ValidateConnection. I need to get the aliyunRDS flag to avoid get the port from database. If don't use the global variable, add a param ( migrationContext may be ) to the function? or any other suggestions ?
shlomi-noach
Mar 28, 2018
Contributor
Indeed it is used there. Sorry, I've missed this.
I still wish to get rid of the global variable. It will not play well with testing and embedding of gh-ost as a library. Please add a migrationContext *MigrationContext argument to base/utils.go ValidateConnection() function and use it.
Indeed it is used there. Sorry, I've missed this.
I still wish to get rid of the global variable. It will not play well with testing and embedding of gh-ost as a library. Please add a migrationContext *MigrationContext argument to base/utils.go ValidateConnection() function and use it.
zhangxiaojian
Mar 29, 2018
Author
Contributor
Branch is updated, thanks for the review.
Branch is updated, thanks for the review.
| var port, extraPort int | ||
| var version string | ||
| if err := db.QueryRow(query).Scan(&port, &version); err != nil { | ||
| if err := db.QueryRow(versionQuery).Scan(&version); err != nil { |
shlomi-noach
Mar 27, 2018
Contributor
I don't see where version is used?
I don't see where version is used?
zhangxiaojian
Mar 28, 2018
Author
Contributor
The version is used in the function Inspector.validateConnection like before, this patch just prevent to get port from database.
The version is used in the function Inspector.validateConnection like before, this patch just prevent to get port from database.
shlomi-noach
Mar 28, 2018
Contributor
Thank you, you are right.
Thank you, you are right.
| @@ -44,6 +44,8 @@ func acceptSignals(migrationContext *base.MigrationContext) { | |||
| // main is the application's entry point. It will either spawn a CLI or HTTP interfaces. | |||
| func main() { | |||
| migrationContext := base.NewMigrationContext() | |||
| base.Context = migrationContext | |||
shlomi-noach
Mar 27, 2018
Contributor
please remove the base.Context global variable.
please remove the base.Context global variable.
shlomi-noach
Mar 27, 2018
Contributor
I actually don't see where it is used.
I actually don't see where it is used.
| return err | ||
| } else { | ||
| this.connectionConfig.ImpliedKey = impliedKey | ||
| if this.migrationContext.AliyunRDS != true { |
shlomi-noach
Mar 27, 2018
Contributor
Please change to if !isAliyunRDS {
Please change to if !isAliyunRDS {
shlomi-noach
Mar 27, 2018
Contributor
Or also see my suggestion to replace the entire block.
Or also see my suggestion to replace the entire block.
zhangxiaojian
Mar 28, 2018
Author
Contributor
Thanks for your suggestion ! replace the entire block makes the code cleaner.
Thanks for your suggestion ! replace the entire block makes the code cleaner.
support-aliyun-rds branch.
|
Looking good. I'll send to testing. |
| return "", err | ||
| } | ||
| extraPortQuery := `select @@global.extra_port` | ||
| if err := db.QueryRow(extraPortQuery).Scan(&extraPort); err != nil { | ||
| // swallow this error. not all servers support extra_port | ||
| } | ||
| // AliyunRDS set users port to "NULL", replace it by gh-ost param |
everpcpc
Mar 29, 2018
•
Maybe this can be changed to a more general option like assume port (int) or validate port (bool)? Then it is not necessary passing migrationContext here.
Besides, mysql running in docker with NAT would also report different port. This kind of option would be useful for similar cases.
Maybe this can be changed to a more general option like assume port (int) or validate port (bool)? Then it is not necessary passing migrationContext here.
Besides, mysql running in docker with NAT would also report different port. This kind of option would be useful for similar cases.
zhangxiaojian
Apr 1, 2018
Author
Contributor
That's a good point, --aliyun-rds is prevent getting port and hostname now, maybe --assume-check or something, @shlomi-noach we may need a product manager to deicide this. : )
That's a good point, --aliyun-rds is prevent getting port and hostname now, maybe --assume-check or something, @shlomi-noach we may need a product manager to deicide this. : )
shlomi-noach
Apr 8, 2018
Contributor
--assume-port sounds good.
Please feel free to choose whether you want to change this in this PR or in a different PR, and let me know.
--assume-port sounds good.
Please feel free to choose whether you want to change this in this PR or in a different PR, and let me know.
zhangxiaojian
Apr 8, 2018
Author
Contributor
I would like to keep --aliyun-rds flags because we can do more things in the future. For example, the slave node is invisible for users and gh-ost cann't request binlog from one of them, maybe we can open a path for gh-ost. --assume-port also make sense, but in a different PR I think.
I would like to keep --aliyun-rds flags because we can do more things in the future. For example, the slave node is invisible for users and gh-ost cann't request binlog from one of them, maybe we can open a path for gh-ost. --assume-port also make sense, but in a different PR I think.
shlomi-noach
Apr 8, 2018
Contributor
Makes sense to me to keep --aliyun-rds.
Makes sense to me to keep --aliyun-rds.
f914b93
into
github:master
|
./gh-ost 2018-06-07 16:17:53 ERROR Error 1885: OPERATION need to be executed set by ADMIN. aliyun rds 读写账号 不可以使用gh-ots 吗? |
|
@zhangxiaojian |


Related issue: #470
Description
This PR makes gh-ost to support Aliyun RDS.
Aliyun RDS is the largest cloud database in China, and the third of the world. For the reason of security and architecture , we need to hide some mysql variables so gh-ost will get ilegal values. This PR add --aliyun-rds flag to avoid getting them.
Usage
For now, users can't connect to the slave node of rds, so gh-ost may working directly on master with flags:
Thanks for gh-ost team developed an excellent tools for online DDL, and hope more people can use it on cloud database.
script/cibuildreturns with no formatting errors, build errors or unit test errors.