Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FATAL ERROR 1105 (HY000): Failed to register slave: too long 'report-host' #388

Open
ealter opened this issue May 9, 2019 · 5 comments
Open

Comments

@ealter
Copy link

ealter commented May 9, 2019

I have been running into this issue when running gh-ost inside of some of our docker containers. When the hostname of the docker container is at least 61 characters in length, I get the following error when trying to run gh-ost.

$ cat /tmp/ghost_user.cnf
[client]
user = ghost
$ /usr/bin/gh-ost --database yelp_pushplan_execution --table pushplan_run --alter ENGINE=InnoDB --conf /tmp/ghost_user.cnf --host xx.xx.xx.xx --chunk-size 500 --force-table-names 1557255792_pushplan_run --assume-rbr
2019/05/07 20:20:05 binlogsyncer.go:79: [info] create BinlogSyncer with config {99999 mysql 10.121.133.170 3306 ghost   false false <nil>}
2019/05/07 20:20:05 binlogsyncer.go:246: [info] begin to sync binlog from position (mysql-bin.000008, 951800672)
2019/05/07 20:20:05 binlogsyncer.go:139: [info] register slave for master server 10.121.133.170:3306
2019-05-07 20:20:05 FATAL ERROR 1105 (HY000): Failed to register slave: too long 'report-host'

The docker container is running on Ubuntu Bionic.

When I specified --hostname when creating the same docker container to be 61 characters instead, gh-ost ran without any issues.

The error message comes from https://github.com/mysql/mysql-server/blob/124c7ab1d6f914637521fd4463a993aa73403513/sql/rpl_master.cc#L161 and it looks like hostname is chosen from https://github.com/siddontang/go-mysql/blob/master/replication/binlogsyncer.go#L495

Let me know if you need any other information to reproduce this.

It looks like this is an actual limit defined in mysql: https://github.com/mysql/mysql-server/blob/124c7ab1d6f914637521fd4463a993aa73403513/sql/sql_const.h#L59

Would it be possible for go-mysql to allow clients to override the hostname used when setting up replication?

@siddontang
Copy link
Collaborator

https://github.com/siddontang/go-mysql/blob/master/replication/binlogsyncer.go#L43

seem we have already had this config, you can use it directly.

arthurhuang added a commit to samsarahq/thunder that referenced this issue Nov 7, 2019
This sets the hostname of the slave hosts to be "localhost". If unset,
as it was, it will use the os.Hostname() value as the hostname instead.

In rare situations, the OS's hostname could be too long for the slave
host's "host" field, and we got an error like:

  panic: ERROR 1105 (HY000): Failed to register slave: too long 'report-host'

which would crash the server.

Before this change:
mysql> show slave hosts;
+------------+--------------------------+------+-----------+------------+
| Server_id  | Host                     | Port | Master_id | Slave_UUID |
+------------+--------------------------+------+-----------+------------+
| 2926146535 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4101280766 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  738891311 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3490062834 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3176772553 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  985189460 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4240725287 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 2752132824 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3221796892 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3038601891 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
+------------+--------------------------+------+-----------+------------+

After this change:
mysql> show slave hosts;
+------------+-----------+------+-----------+------------+
| Server_id  | Host      | Port | Master_id | Slave_UUID |
+------------+-----------+------+-----------+------------+
|  186920018 | localhost | 3308 |         1 |            |
| 2071718504 | localhost | 3308 |         1 |            |
| 3278845420 | localhost | 3308 |         1 |            |
| 2121800266 | localhost | 3308 |         1 |            |
| 3721418580 | localhost | 3308 |         1 |            |
| 3544321535 | localhost | 3308 |         1 |            |
|   50012544 | localhost | 3308 |         1 |            |
| 4141694557 | localhost | 3308 |         1 |            |
| 1374039930 | localhost | 3308 |         1 |            |
+------------+-----------+------+-----------+------------+

It doesn't seem like the hostname of the slave hosts matters that much;
Verified everything still worked as expected.

Also see go-mysql-org/go-mysql#388
arthurhuang added a commit to samsarahq/thunder that referenced this issue Nov 11, 2019
This sets the localhost field of the BinlogSyncerConfig. If unset,
as it was, it will use the os.Hostname() value as the hostname instead.

In rare situations, the OS's hostname could be too long for the slave
host's "host" field, and we got an error like:

  panic: ERROR 1105 (HY000): Failed to register slave: too long 'report-host'

which would crash the server. So we strip the hostname to be 60
characters, which is the max allowed length.

It doesn't seem like the hostname of the slave hosts matters that much;
Verified everything still worked as expected. We could hardcode
"localhost" here as the host name but are keeping the OS's hostname in
case it's useful for debugging on remote hosts.

To see the hostname of slave hosts:
mysql> show slave hosts;
+------------+--------------------------+------+-----------+------------+
| Server_id  | Host                     | Port | Master_id | Slave_UUID |
+------------+--------------------------+------+-----------+------------+
| 2926146535 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4101280766 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  738891311 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3490062834 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3176772553 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  985189460 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4240725287 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 2752132824 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3221796892 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3038601891 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
+------------+--------------------------+------+-----------+------------+

Also see go-mysql-org/go-mysql#388
arthurhuang added a commit to samsarahq/thunder that referenced this issue Nov 12, 2019
This sets the localhost field of the BinlogSyncerConfig. If unset,
as it was, it will use the os.Hostname() value as the hostname instead.

In rare situations, the OS's hostname could be too long for the slave
host's "host" field, and we got an error like:

  panic: ERROR 1105 (HY000): Failed to register slave: too long 'report-host'

which would crash the server. So we strip the hostname to be 60
characters, which is the max allowed length.

It doesn't seem like the hostname of the slave hosts matters that much;
Verified everything still worked as expected. We could hardcode
"localhost" here as the host name but are keeping the OS's hostname in
case it's useful for debugging on remote hosts.

To see the hostname of slave hosts:
mysql> show slave hosts;
+------------+--------------------------+------+-----------+------------+
| Server_id  | Host                     | Port | Master_id | Slave_UUID |
+------------+--------------------------+------+-----------+------------+
| 2926146535 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4101280766 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  738891311 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3490062834 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3176772553 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  985189460 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4240725287 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 2752132824 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3221796892 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3038601891 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
+------------+--------------------------+------+-----------+------------+

Also see go-mysql-org/go-mysql#388
arthurhuang added a commit to samsarahq/thunder that referenced this issue Nov 15, 2019
This sets the localhost field of the BinlogSyncerConfig. If unset,
as it was, it will use the os.Hostname() value as the hostname instead.

In rare situations, the OS's hostname could be too long for the slave
host's "host" field, and we got an error like:

  panic: ERROR 1105 (HY000): Failed to register slave: too long 'report-host'

which would crash the server. So we strip the hostname to be 60
characters, which is the max allowed length.

It doesn't seem like the hostname of the slave hosts matters that much;
Verified everything still worked as expected. We could hardcode
"localhost" here as the host name but are keeping the OS's hostname in
case it's useful for debugging on remote hosts.

To see the hostname of slave hosts:
mysql> show slave hosts;
+------------+--------------------------+------+-----------+------------+
| Server_id  | Host                     | Port | Master_id | Slave_UUID |
+------------+--------------------------+------+-----------+------------+
| 2926146535 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4101280766 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  738891311 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3490062834 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3176772553 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
|  985189460 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 4240725287 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 2752132824 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3221796892 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
| 3038601891 | Arthur-Huang-MacBook-Pro | 3308 |         1 |            |
+------------+--------------------------+------+-----------+------------+

Also see go-mysql-org/go-mysql#388
@lance6716
Copy link
Collaborator

I also met this problem, and seems different version of MySQL has different length limit, it's better let the application of this library to decide the hostname

https://github.com/mysql/mysql-server/blob/1bfe02bdad6604d54913c62614bde57a055c8332/include/my_hostname.h#L33-L42

@ljw7630
Copy link

ljw7630 commented Jan 2, 2024

normally, what we do is

canal := NewCanal(cfg)
canal.Run()

there's no way for developers to inject custom binlogsyncer to canal. so event BinlogSyncerConfig itself have a public field call LocalHost, it does not help

@lance6716
Copy link
Collaborator

normally, what we do is

canal := NewCanal(cfg) canal.Run()

there's no way for developers to inject custom binlogsyncer to canal. so event BinlogSyncerConfig itself have a public field call LocalHost, it does not help

You can set canal.Config.Localhost

@ljw7630
Copy link

ljw7630 commented Jan 2, 2024

normally, what we do is
canal := NewCanal(cfg) canal.Run()
there's no way for developers to inject custom binlogsyncer to canal. so event BinlogSyncerConfig itself have a public field call LocalHost, it does not help

You can set canal.Config.Localhost

oh. cool. our repo is using v1.6.0, so this param is not available. but i check latest version, it has this setting. I think this will do the trick. Thank you.

But it looks like this change is not included in v1.7.0, setting our go module directly depends on latest might bring unexpected result though.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants