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

Commit

Permalink
go livesql/binlog: set Localhost in binlogSyncerConfig
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arthurhuang committed Nov 7, 2019
1 parent c818dd3 commit 36e9138
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions livesql/binlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func NewBinlogWithSource(ldb *LiveDB, sourceDB *sql.DB, host string, port uint16
syncer := replication.NewBinlogSyncer(&replication.BinlogSyncerConfig{
ServerID: binary.LittleEndian.Uint32(slaveId),
Host: host,
Localhost: "localhost",
Port: port,
User: username,
Password: password,
Expand Down

0 comments on commit 36e9138

Please # to comment.