| Bug #106635 | MySQL Router config_generator url.host configuration | ||
|---|---|---|---|
| Submitted: | 4 Mar 2022 3:43 | Modified: | 11 Mar 2022 10:15 |
| Reporter: | bin wang (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Router | Severity: | S3 (Non-critical) |
| Version: | Ver 8.0.28 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | Contribution, router | ||
[4 Mar 2022 3:43]
bin wang
suggested add patch
Attachment: config_generator.patch (application/octet-stream, text), 421 bytes.
[4 Mar 2022 7:17]
MySQL Verification Team
Hello bin wang, Thank you for the report and contribution. Please ensure to re-send the patch via "contribution" tab. Otherwise we would not be able to accept it. Thank you! regards, Umesh
[4 Mar 2022 7:21]
bin wang
ok suggested add patch (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: config_generator.patch (application/octet-stream, text), 421 bytes.
[7 Mar 2022 10:52]
Ulf Wendel
Posted by developer: I don't understand the goal, please explain. Are you asking to use sockets by default when bootstrapping? Bootstrap refers to reading metadata from an InnoDB Cluster to setup a base configuration. InnoDB Cluster is a distributed database with TCP/IP based communication between the elements of the cluster setup. Using a socket connection from Router to any of the InnoDB Cluster members for boostrap seems to have no significant advantage. When Router is not boostraped against a primary (using socket) it will automatically reconnect to the current primary (using TCP/IP). TCP/IP connections must be enabled within the cluster anyway, otherwise there will be no replication. And, as of MySQL 8.0.27, GR can be configured to use the MySQL protocol stack (https://dev.mysql.com/doc/refman/8.0/en/group-replication-options.html#sysvar_group_replic...) for communication which reduces the number of ports and simplifies work needed to block external traffic. All in all a change to socket by default seems not useful. But maybe I don't understand: a diff along does not explain the objectives behind a change.
[11 Mar 2022 2:23]
bin wang
Thank you for your replay
the add code here is not using sockets by default when bootstrapping
+ } else {
+ // setup localhost ip address.
+ u.host = (u.host == "localhost" ? "127.0.0.1" : u.host);
}
different is
127.0.0.1 using tcp/ip
localhost using local socket
if bootstrap_socket.size=0
means use tcp/ip to connect
the add code
if bootstrap_socket.size=0 and u.host == "localhost"
u.host setup localhost address will be better.
then connection to server use 127.0.0.1(tcp/ip)

Description: mysql-8.0.28\router\src\router\src\config_generator.cc ................. line 354 if (bootstrap_socket.size() > 0) { // enforce host == "localhost" if a socket is used to avoid ambiguity with // the possible hostname if (u.host != "localhost") { throw std::runtime_error( "--bootstrap-socket given, but --bootstrap option contains a " "non-'localhost' hostname: " + u.host); } } ........... if bootstrap_socket is not given it will connect server through TCP/IP instead of local socket. u.host change to ip address will be better. How to repeat: change u.host to a ip address mysql-8.0.28\router\src\router\src\config_generator.cc ................. line 354 if (bootstrap_socket.size() > 0) { // enforce host == "localhost" if a socket is used to avoid ambiguity with // the possible hostname if (u.host != "localhost") { throw std::runtime_error( "--bootstrap-socket given, but --bootstrap option contains a " "non-'localhost' hostname: " + u.host); } + } else { + // setup localhost ip address. + u.host = (u.host == "localhost" ? "127.0.0.1" : u.host); } ........... Suggested fix: mysql-8.0.28\router\src\router\src\config_generator.cc ................. line 354 if (bootstrap_socket.size() > 0) { // enforce host == "localhost" if a socket is used to avoid ambiguity with // the possible hostname if (u.host != "localhost") { throw std::runtime_error( "--bootstrap-socket given, but --bootstrap option contains a " "non-'localhost' hostname: " + u.host); } + } else { + // setup localhost ip address. + u.host = (u.host == "localhost" ? "127.0.0.1" : u.host); } ...........