Bug #92128 definer does not exist when issuing the command dba.getCluster()
Submitted: 22 Aug 2018 15:32 Modified: 25 Nov 2019 10:05
Reporter: Truphone DBA Email Updates:
Status: Closed Impact on me:
None 
Category:Shell AdminAPI InnoDB Cluster / ReplicaSet Severity:S3 (Non-critical)
Version:8.0.12 OS:Any
Assigned to: CPU Architecture:Any

[22 Aug 2018 15:32] Truphone DBA
Description:
Using MySQL Shell 8.0.12 when issuing the command dba.getCluster() we get the following error:
==================
The user specified as a definer ('trudba'@'%') does not exist (MySQL Error 1449)
==================

How to repeat:
using shell 8.0.12:

dba.verbose=true
dba.deploySandboxInstance(3310,{password:'cluster'})
dba.deploySandboxInstance(3320,{password:'cluster'})
dba.deploySandboxInstance(3330,{password:'cluster'})

\sql
 \connect root:cluster@localhost:3310
 set sql_log_bin=0;CREATE USER 'cluster'@'%' IDENTIFIED BY 'cluster';GRANT ALL PRIVILEGES ON *.* TO 'cluster'@'%'    WITH GRANT OPTION;set sql_log_bin=1;
 \connect root:cluster@localhost:3320
set sql_log_bin=0;CREATE USER 'cluster'@'%' IDENTIFIED BY 'cluster';GRANT ALL PRIVILEGES ON *.* TO 'cluster'@'%'    WITH GRANT OPTION;set sql_log_bin=1;
 \connect root:cluster@localhost:3330
set sql_log_bin=0;CREATE USER 'cluster'@'%' IDENTIFIED BY 'cluster';GRANT ALL PRIVILEGES ON *.* TO 'cluster'@'%'    WITH GRANT OPTION;set sql_log_bin=1;

\js
\connect cluster:cluster@localhost:3310
var cluster = dba.createCluster('testCluster')
cluster.addInstance("cluster@localhost:3320",{password:'cluster'})
cluster.addInstance("cluster@localhost:3330",{password:'cluster'})

dba.configureLocalInstance('cluster:cluster@localhost:3310')
dba.configureLocalInstance('cluster:cluster@localhost:3320')
dba.configureLocalInstance('cluster:cluster@localhost:3330')

\sql
rename user cluster to 'cluster'@'192.168.56.%';

\q

mysqlsh --uri cluster:cluster@192.168.56.101:3320
The user specified as a definer ('cluster'@'%') does not exist (MySQL Error 1449)

--
In Shell error log we see:

2018-08-22 15:26:01: Info: mysql://cluster@192.168.56.101:3320 is not a primary, will try to find one and reconnect
2018-08-22 15:26:01: Error: The user specified as a definer ('cluster'@'%') does not exist
--

Suggested fix:
dba.getCluster() should return the cluster not an error.
[23 Aug 2018 5:52] MySQL Verification Team
Hello!

Thank you for the report, steps to reproduce the issue.
Verified as described.

regards,
Umesh
[24 Aug 2018 10:46] Truphone DBA
Thanks Umesh for taking take of this Bug.

Adding, if anyone else does stumble with this issue, possible workarounds:
-Connect to a primary node
-Set connectToPrimary to false, something like:
dba.getCluster('myCluster',{connectToPrimary: false})

Kind Regards,
Truphone DBA
[20 Sep 2018 17:57] Miguel Araujo
Posted by developer:
 
The issue seen is caused by the renaming of the clusterAdmin which is the definer of internal VIEWS created by the Shell when the cluster is created.
Since the user does not exist anymore (it was renamed), the views cannot be executed anymore.

Workaround: If renaming the user is really necessary, the VIEWS (schema_version) must be altered beforehand the renaming in order to change the definer to be the "new" user.
[25 Nov 2019 10:05] David Moss
Posted by developer:
 
Thank you for your feedback, this has been fixed in upcoming versions and the following was added to the 8.0.19 changelog:

If you changed the name of the clusterAdmin user once a cluster had been created, you could encounter an error such as The user specified as a definer does not exist. This was because the clusterAdmin user was used as the DEFINER of the views required by InnoDB cluster, and if this user is renamed then the definer is in effect missing. In version 8.0.19 the InnoDB cluster metadata has been changed to avoid this problem, use dba.upgradeMetadata() to upgrade the cluster. Clusters deployed with 8.0.19 and later do not suffer from this issue.