Bug #85342 Cluster.addInstance fails when adding a node
Submitted: 7 Mar 2017 14:30 Modified: 11 May 2018 19:32
Reporter: Eduardo Alapisco Arambula Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Document Store: MySQL Shell Severity:S1 (Critical)
Version:1.0.8-rc OS:Any
Assigned to: CPU Architecture:Any

[7 Mar 2017 14:30] Eduardo Alapisco Arambula
Description:
With the shell I created a cluster in multimaster mode , dissolved it , created it again in single primary mode , but when I tried rejoining the additional nodes I get an error.

Cluster.addInstance: Cannot add or update a child row: a foreign key
constraint fails (`mysql_innodb_cluster_metadata`.`instances`,
CONSTRAINT `instances_ibfk_2` FOREIGN KEY (`replicaset_id`) REFERENCES
`replicasets` (`replicaset_id`) ON DELETE SET NULL) (MySQL Error 1452)

The same happens when switching from single primary to multimaster. 

How to repeat:
1- dba.deploySandboxInstance(3310,{sandboxDir:"/home/james/sandboxes" ,
portx:3320, password:"password" , allowRootFrom:"%"})

2.- dba.deploySandboxInstance(3330,{sandboxDir:"/home/james/sandboxes" ,
portx:3340, password:"password" , allowRootFrom:"%"})

3.- \connect -c root:password@localhost:3310 

4.- dba.createCluster('cluster1',{multiMaster:true,force:true})

5.- cluster = dba.getCluster('cluster1');

6.- cluster.addInstance({user:"root", password:"password", host:"localhost", port:3330});

7.- cluster.dissolve({force:true})

8.- dba.createCluster('cluster1',{multiMaster:false,force:true})

9.- cluster.addInstance({user:"root", password:"password", host:"localhost", port:3330});
[11 May 2018 19:33] Hema Sridharan
[From Dev Team]

Could not reproduce the issue (not a bug).
 

 
 
In the description, the second createCluster() (step 8) was executed without
assigning the new cluster to a variable and the old cluster variable is used
in the next operation (step 9) to add the instance which will lead to an
expected error, however after getting the new cluster variable the
addInstance() will execute successfully.
 
 
 
{noformat}
 
mysql-js> dba.deploySandboxInstance(3310, {portx:3320, password:"password",
allowRootFrom:"%"});
 
Deploying new MySQL instance...
 
 
 
Instance localhost:3310 successfully deployed and started.
 
Use shell.connect('root@localhost:3310'); to connect to the instance.
 
 
 
mysql-js> dba.deploySandboxInstance(3330, {portx:3340, password:"password",
allowRootFrom:"%"});
 
Deploying new MySQL instance...
 
 
 
Instance localhost:3330 successfully deployed and started.
 
Use shell.connect('root@localhost:3330'); to connect to the instance.
 
 
 
mysql-js> \connect -c root:password@localhost:3310
 
Creating a Classic Session to 'root@localhost:3310'
 
Closing old connection...
 
Session successfully established. No default schema selected.
 
mysql-js> dba.createCluster('cluster1', {multiMaster:true,force:true})
 
A new InnoDB cluster will be created on instance 'root@localhost:3310'.
 
 
 
Creating InnoDB cluster 'cluster1' on 'root@localhost:3310'...
 
Adding Seed Instance...
 
 
 
Cluster successfully created. Use Cluster.addInstance() to add MySQL
instances.
 
At least 3 instances are needed for the cluster to be able to withstand up to
 
one server failure.
 
 
 
<Cluster:cluster1>
 
mysql-js>  cluster = dba.getCluster('cluster1');
 
<Cluster:cluster1>
 
mysql-js> cluster.addInstance({user:"root", password:"password",
host:"localhost", port:3330});
 
A new instance will be added to the InnoDB cluster. Depending on the amount
of
 
data on the cluster this might take from a few seconds to several hours.
 
 
 
Adding instance to the cluster ...
 
 
 
The instance 'root@localhost:3330' was successfully added to the cluster.
 
 
 
mysql-js> cluster.dissolve({force:true});
 
The cluster was successfully dissolved.
 
Replication was disabled but user data was left intact.
 
 
 
mysql-js> dba.createCluster('cluster1', {multiMaster:false,force:true});
 
A new InnoDB cluster will be created on instance 'root@localhost:3310'.
 
 
 
Creating InnoDB cluster 'cluster1' on 'root@localhost:3310'...
 
Adding Seed Instance...
 
 
 
Cluster successfully created. Use Cluster.addInstance() to add MySQL
instances.
 
At least 3 instances are needed for the cluster to be able to withstand up to
 
one server failure.
 
 
 
<Cluster:cluster1>
 
mysql-js> cluster.addInstance({user:"root", password:"password",
host:"localhost", port:3330});
 
Cluster.addInstance: Can't call function 'addInstance' on a dissolved cluster
(RuntimeError)
 
mysql-js>  cluster = dba.getCluster('cluster1');
  <Cluster:cluster1>
 
mysql-js> cluster.addInstance({user:"root", password:"password",
host:"localhost", port:3330});
 
A new instance will be added to the InnoDB cluster. Depending on the amount
of
 
data on the cluster this might take from a few seconds to several hours.
 
 
 
Adding instance to the cluster ...
 
 
 
The instance 'root@localhost:3330' was successfully added to the cluster.
 
 
 
mysql-js>
 
{noformat}