Description:
MySQL shell is generating non-valid JSON when calling dba.get_cluster().status() when quorum has been lost since it escapes the single quotes in "Cluster has no quorum as visible from '127.0.0.1:3306'".
How to repeat:
- Start a simple cluster with a single primary, 3 members total
- Kill 2 of the 3 members without deleting the underlying data for the members. This causes the cluster to lose quorum.
Connect via mysqlsh and execute:
> s = dba.get_cluster().status()
> print s
{"clusterName": "MySQLCluster", "defaultReplicaSet": {"name": "default", "primary": "mysql-0.mysql:3306", "ssl": "REQUIRED", "status": "NO_QUORUM", "statusText": "Cluster has no quorum as visible from \'127.0.0.1:3306\' and cannot process write transactions. 2 members are not active", "topology": {"mysql-0.mysql:3306": {"address": "mysql-0.mysql:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "UNREACHABLE"}, "mysql-1.mysql:3306": {"address": "mysql-1.mysql:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "UNREACHABLE"}, "mysql-2.mysql:3306": {"address": "mysql-2.mysql:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE"}}}, "groupInformationSourceMember": "mysql://root@127.0.0.1:3306"}
>
> import json
> json.loads(str(s))
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Invalid \escape: line 1 column 202 (char 201)
Suggested fix:
Don't escape https://github.com/mysql/mysql-shell/blob/02f74a53ff4c9a4eab3d411b8263d940263f9169/modules...)
Description: MySQL shell is generating non-valid JSON when calling dba.get_cluster().status() when quorum has been lost since it escapes the single quotes in "Cluster has no quorum as visible from '127.0.0.1:3306'". How to repeat: - Start a simple cluster with a single primary, 3 members total - Kill 2 of the 3 members without deleting the underlying data for the members. This causes the cluster to lose quorum. Connect via mysqlsh and execute: > s = dba.get_cluster().status() > print s {"clusterName": "MySQLCluster", "defaultReplicaSet": {"name": "default", "primary": "mysql-0.mysql:3306", "ssl": "REQUIRED", "status": "NO_QUORUM", "statusText": "Cluster has no quorum as visible from \'127.0.0.1:3306\' and cannot process write transactions. 2 members are not active", "topology": {"mysql-0.mysql:3306": {"address": "mysql-0.mysql:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "UNREACHABLE"}, "mysql-1.mysql:3306": {"address": "mysql-1.mysql:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "UNREACHABLE"}, "mysql-2.mysql:3306": {"address": "mysql-2.mysql:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE"}}}, "groupInformationSourceMember": "mysql://root@127.0.0.1:3306"} > > import json > json.loads(str(s)) Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads return _default_decoder.decode(s) File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode obj, end = self.scan_once(s, idx) ValueError: Invalid \escape: line 1 column 202 (char 201) Suggested fix: Don't escape https://github.com/mysql/mysql-shell/blob/02f74a53ff4c9a4eab3d411b8263d940263f9169/modules...)