Skip to content

Mysql server refresh failed to create a database role required by newer version of the router #151

@gustavosr98

Description

@gustavosr98

Steps to reproduce

Deploy mysql (8.0/stable | rev 255) and mysql-router (8.0/stable | rev 748)
Refresh mysql (8.0/stable | rev 346) and mysql-router (8.0/stable | rev 871)

WARN: Do not directly run juju refresh <app> but rather follow pre-checks first juju run mysql-k8s/leader pre-upgrade-check . https://canonical-charmed-mysql.readthedocs-hosted.com/how-to/refresh/single-cluster/refresh-single-cluster/

You will hit this bug canonical/mysql-router-operators#100

Then to find a workaround for it you will hit this bug (current report)

Remove mysql-router

juju remove-application mysql-router

Deploy mysql-router latest version (8.0/stable | rev 871)
Relate mysql-router to mysql

Expected behavior

To be in active state properly related to mysql

Actual behavior

Mysql-router stuck waiting for "Waiting for mysql app on backend-database endpoint"
The k8s endpoint actually exists and the juju application is trusted

# juju status --relations | grep placement-mysql-router
placement-mysql-router      8.0.44                   waiting      3  mysql-router-k8s          8.0/stable     871  10.152.183.54   no       Waiting for mysql app on backend-database endpoint
placement-mysql-router/0       waiting   idle   10.1.1.25
placement-mysql-router/1       waiting   idle   10.1.2.60
placement-mysql-router/2*      waiting   idle   10.1.0.216
mysql:database                                        placement-mysql-router:backend-database        mysql_client             regular
placement-mysql-router:cos                            placement-mysql-router:cos                     cos                      peer
placement-mysql-router:database                       placement:database                             mysql_client             regular
placement-mysql-router:mysql-router-peers             placement-mysql-router:mysql-router-peers      mysql_router_peers       peer
placement-mysql-router:refresh-v-three                placement-mysql-router:refresh-v-three         refresh                  peer
placement-mysql-router:tls                            placement-mysql-router:tls                     tls                      peer

Versions

Juju agent: 3.6.12
Cloud type: Kubernetes

Log output

2026-03-09T22:16:43.244Z [container-agent] 2026-03-09 22:16:43 ERROR juju-log database:257: Failed to execute mysql-shell command
2026-03-09T22:16:43.244Z [container-agent] Traceback (most recent call last):
2026-03-09T22:16:43.244Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/src/mysql_k8s_helpers.py", line 719, in _run_mysqlsh_script
2026-03-09T22:16:43.244Z [container-agent]     stdout, _ = process.wait_output()
2026-03-09T22:16:43.244Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/venv/lib/python3.10/site-packages/ops/pebble.py", line 1771, in wait_output
2026-03-09T22:16:43.244Z [container-agent]     raise ExecError[AnyStr](self._command, exit_code, out_value, err_value)
2026-03-09T22:16:43.244Z [container-agent] ops.pebble.ExecError: non-zero exit code 1 executing ['/usr/bin/mysqlsh', '--passwords-from-stdin', '--uri=serverconfig@mysql-1.mysql-endpoints.openstack.svc.cluster.local.:33062', '--python', '--verbose=0', '-c', 'shell.options.set(\'useWizards\', False)\nprint(\'###\')\nshell.connect_to_primary()\nsession.run_sql("CREATE USER `relation-257_9265fb6a20e24`@`%` IDENTIFIED BY \'*****\' ATTRIBUTE \'{}\';")\nsession.run_sql("GRANT mysqlrouter TO `relation-257_9265fb6a20e24`@`%`;")'], stdout="\x1b[1mPlease provide the password for 'serverconfig@mysql-1.mysql-endpoints.openstack.svc.cluster.local.:33062': \x1b[0m###\nReconnecting to the PRIMARY instance of an InnoDB cluster (mysql-2.mysql-endpoints.openstack.svc.cluster.local.:3306)...\n", stderr='Cannot set LC_ALL to locale en_US.UTF-8: No such file or directory\nTraceback (most recent call last):\n  File "<string>", line 5, in <module>\nmysqlsh.DBError: MySQL Error (3523): ClassicSession.run_sql: Unknown authorization ID `mysqlrouter`@`%`\n'
2026-03-09T22:16:43.258Z [container-agent] 2026-03-09 22:16:43 ERROR juju-log database:257: Failed to create application scoped user relation-257_9265fb6a20e24@%
2026-03-09T22:16:43.271Z [container-agent] 2026-03-09 22:16:43 ERROR juju-log database:257: Failed to set up database relation
2026-03-09T22:16:43.271Z [container-agent] Traceback (most recent call last):
2026-03-09T22:16:43.271Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/lib/charms/mysql/v0/mysql.py", line 1670, in create_scoped_user
2026-03-09T22:16:43.271Z [container-agent]     self._run_mysqlsh_script(
2026-03-09T22:16:43.271Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py", line 1065, in wrapped_function
2026-03-09T22:16:43.271Z [container-agent]     return callable(*args, **kwargs)  # type: ignore
2026-03-09T22:16:43.271Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/src/mysql_k8s_helpers.py", line 727, in _run_mysqlsh_script
2026-03-09T22:16:43.271Z [container-agent]     raise MySQLClientError from None
2026-03-09T22:16:43.271Z [container-agent] charms.mysql.v0.mysql.MySQLClientError
2026-03-09T22:16:43.271Z [container-agent]
2026-03-09T22:16:43.271Z [container-agent] The above exception was the direct cause of the following exception:
2026-03-09T22:16:43.271Z [container-agent]
2026-03-09T22:16:43.271Z [container-agent] Traceback (most recent call last):
2026-03-09T22:16:43.271Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/src/relations/mysql_provider.py", line 144, in _on_database_requested
2026-03-09T22:16:43.271Z [container-agent]     self.charm._mysql.create_scoped_user(
2026-03-09T22:16:43.271Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py", line 1065, in wrapped_function
2026-03-09T22:16:43.271Z [container-agent]     return callable(*args, **kwargs)  # type: ignore
2026-03-09T22:16:43.271Z [container-agent]   File "/var/lib/juju/agents/unit-mysql-1/charm/lib/charms/mysql/v0/mysql.py", line 1680, in create_scoped_user
2026-03-09T22:16:43.271Z [container-agent]     raise MySQLCreateApplicationScopedUserError(e.message) from e
2026-03-09T22:16:43.271Z [container-agent] charms.mysql.v0.mysql.MySQLCreateApplicationScopedUserError
2026-03-09T22:16:44.810Z [container-agent] 2026-03-09 22:16:44 DEBUG juju-log database:257: ops 2.15.0 up and running.

Additional context

Related to sunbeam cluster refresh
https://bugs.launchpad.net/snap-openstack/+bug/2143746

On recent sunbeam stable release
https://discourse.charmhub.io/t/sunbeam-release-2024-1-stable-rev-922/19941

Metadata

Metadata

Assignees

Labels

bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions