Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Hello,
cmapi detects master with
SELECT VARIABLE_VALUE FROM information_schema.GLOBAL_STATUS WHERE VARIABLE_NAME = 'SLAVE_CONNECTIONS';
SLAVE_CONNECTIONS is defined as
"Number of REGISTER_SLAVE attempts. In practice the number of times slaves has tried to connect to the master. "
https://mariadb.com/kb/en/replication-and-binary-log-status-variables/#slave_connections
It is a counter, which will not be reseted, if the server is no master anymore, so this will not safely detects a master.
|
# returns a pair of bools
|
# the first indicates whether the node is the master
|
# the second indicates if the calling functions retry loop should continue |
def _is_master(node, root):
|
ces_node = root.find("./CrossEngineSupport") |
username = ces_node.find("./User").text |
password = ces_node.find("./Password").text |
|
if username is None: |
return False, False |
|
cmd = (f"mariadb -h {node} -u '{username}' --password='{password}' -sN -e \ |
\"SELECT VARIABLE_VALUE FROM information_schema.GLOBAL_STATUS WHERE VARIABLE_NAME = 'SLAVE_CONNECTIONS';\"") |
|
ret = subprocess.run(cmd, stdout=subprocess.PIPE, shell = True)
|
if ret.returncode == 0: |
response = ret.stdout.decode("utf-8").strip() |
if response > '0': |
return True, False |
else: |
return False, False |
return False, True |
Maybe the suggestion from Todd in MCOL-4289 is more safe,
SELECT COUNT(1) AS `slave_threads` |
|
FROM `information_schema`.`PROCESSLIST`
|
|
WHERE `USER`='system user' |
|
AND `COMMAND` LIKE 'Slave%'; |
Attachments
Issue Links
- relates to
-
MCOL-4763 CMAPI status shows wrong node as master/mismatch with maxscale (failover related)(on prem)
- Closed