Bug #95010 custer.setOption("clusterName","myNewClusterName") breaks InnoDb Cluster
Submitted: 12 Apr 2019 15:41 Modified: 9 Feb 2023 10:58
Reporter: Truphone DBA Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Router Severity:S2 (Serious)
Version:8.0.15 OS:Any
Assigned to: CPU Architecture:Any

[12 Apr 2019 15:41] Truphone DBA
Description:
While performing a simple cluster rename, the InnoDB Cluster solution was broken.

In the application host we could not connect to InnoDB Cluster:
----
 mysqlsh -h localhost --port 6446  -u nRoot
Please provide the password for 'nRoot@localhost:6446': ***************
MySQL Shell 8.0.15-commercial
Creating a session to 'nRoot@localhost:6446'
ERROR: MySQL Error 2003 (HY000): Can't connect to remote MySQL server for client connected to '0.0.0.0:6446'
----

How to repeat:
using mysql shell

1 -\c root@127.0.0.1
2 - c=dba.getCluster()
3 -  c.setOption("clusterName","myNewClusterName")
----
  Successfully set the value of 'clusterName' to 'myNewClusterName' in the Cluster: 'DBCluster'.
----
4- Cant connect to cluster using 6446 port provided by mysql router

router error log:
-----
2019-04-12 15:47:57 metadata_cache ERROR [7fd52da37700] Failed fetching metadata from any of the 3 metadata servers.
2019-04-12 15:47:58 metadata_cache WARNING [7fd52da37700] No replicasets defined for cluster 'DBCluster'
2019-04-12 15:47:58 metadata_cache WARNING [7fd52da37700] Tried node ee16e5b4-57e3-11e9-96fb-005056b4f3fe on host 10.21.175.74, port 3306 as a metadata server, it does not contan metadata for replication group 494b2bb0-57e4-11e9-836a-005056b4f3fe
2019-04-12 15:47:58 metadata_cache WARNING [7fd52da37700] No replicasets defined for cluster 'DBCluster'
2019-04-12 15:47:58 metadata_cache WARNING [7fd52da37700] Tried node ece976cc-57e3-11e9-9351-005056b4d74f on host 10.21.175.75, port 3306 as a metadata server, it does not contan metadata for replication group 494b2bb0-57e4-11e9-836a-005056b4f3fe
2019-04-12 15:47:58 metadata_cache WARNING [7fd52da37700] No replicasets defined for cluster 'DBCluster'
2019-04-12 15:47:58 metadata_cache WARNING [7fd52da37700] Tried node ed9541e0-57e3-11e9-ba44-005056b491b4 on host 10.21.175.76, port 3306 as a metadata server, it does not contan metadata for replication group 494b2bb0-57e4-11e9-836a-005056b4f3fe

-----

Suggested fix:
Performing a custer.setOption("clusterName","myNewClusterName") should not break cluster functionality

As summary of the performed actions:
Scenario A
cluster rename->router error->cluster rename original name->router ok

Scenario B
cluster rename->router error->router restart>router error->cluster rename original name->router error

Scenario C
cluster rename->router error->router restart>router error->cluster rename original name->router error>router bootstrap>router error>router restart>router ok
[12 Apr 2019 15:48] Truphone DBA
The bug https://bugs.mysql.com/bug.php?id=94057 covers some of this use case, but not all.

Does not make sense that a cluster rename involving a router bootstraping and restart in order to work.
[9 Feb 2023 10:58] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Router 8.0.33 release notes:
	
  Renaming a cluster, using cluster.setOption(), caused routing to fail due to an issue with MySQL Router
  configuration. This issue was caused by MySQL Router using the cluster name written to the MySQL Router
  configuration file during bootstrapping. The cluster name was then used in queries to the metadata cache, 
  which failed when the cluster was renamed.

  As of this release, the cluster name is not used, the UUID is used instead. That is, Group Replication UUID for
  group replication clusters, ClusterSet UUID for ClusterSets, and Cluster UUID for ReplicaSet clusters.
  The UUID is written to MySQL Router's JSON state file.
  Note
  For backward compatibility, the cluster name is still written to the configuration file and will be used if
  UUIDs are not available.