Skip to content

Commit

Permalink
fix(mysql): mysql元数据检查部分项丢失实例信息 #8818
Browse files Browse the repository at this point in the history
  • Loading branch information
xfwduke committed Dec 25, 2024
1 parent e8c8298 commit 6d8bc3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
_cluster_slave_as_receiver,
)
from backend.db_periodic_task.local_tasks.db_meta.db_meta_check.mysql_cluster_topo.tendbha.status import (
_cluster_instance_status,
_cluster_master_entry_count,
_cluster_master_status,
_cluster_one_master,
Expand Down Expand Up @@ -70,19 +71,23 @@ def health_check(cluster_id: int) -> List[CheckResponse]:
cluster_obj = qs.get(id=cluster_id)

res = []

res.extend(_cluster_status(cluster_obj))
# unique_cluster.py
res.extend(_cluster_instance_unique_cluster(cluster_obj))
# status.py
res.extend(_cluster_status(cluster_obj))
res.extend(_cluster_instance_status(cluster_obj))
res.extend(_cluster_master_entry_count(cluster_obj))
res.extend(_cluster_proxy_count(cluster_obj))
res.extend(_cluster_one_master(cluster_obj))
res.extend(_cluster_master_status(cluster_obj))
res.extend(_cluster_one_standby_slave(cluster_obj))
res.extend(_cluster_standby_slave_status(cluster_obj))
# entry_bind.py
res.extend(_cluster_master_entry_on_proxy(cluster_obj))
res.extend(_cluster_master_entry_on_storage(cluster_obj))
res.extend(_cluster_entry_real_bind(cluster_obj))
res.extend(_cluster_proxy_access_master(cluster_obj))
# replicate.py
res.extend(_cluster_master_as_ejector(cluster_obj))
res.extend(_cluster_slave_as_receiver(cluster_obj))
res.extend(_cluster_replicate_out(cluster_obj))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from typing import List

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from backend.db_meta.enums import ClusterEntryRole, ClusterStatus, InstanceInnerRole, InstancePhase, InstanceStatus
from backend.db_meta.models import Cluster
Expand Down Expand Up @@ -153,9 +153,7 @@ def _cluster_one_standby_slave(


@checker_wrapper
def _cluster_standby_slave_status(
c: Cluster,
) -> List[CheckResponse]:
def _cluster_standby_slave_status(c: Cluster) -> List[CheckResponse]:
"""
standby slave 必须正常
"""
Expand All @@ -164,12 +162,12 @@ def _cluster_standby_slave_status(
if (si.instance_inner_role == InstanceInnerRole.SLAVE and si.is_stand_by is True) and (
si.status != InstanceStatus.RUNNING or si.phase != InstancePhase.ONLINE
):
bad.append(si)

if bad:
return [
CheckResponse(
msg=_("standby slave 状态异常: {}".format(",".join([ele.ip_port for ele in bad]))),
check_subtype=MetaCheckSubType.ClusterTopo,
bad.append(
CheckResponse(
msg=_("standby slave {} 状态异常: {}, {}".format(si.ip_port, si.status, si.phase)),
check_subtype=MetaCheckSubType.ClusterTopo,
instance=si,
)
)
]

return bad

0 comments on commit 6d8bc3d

Please sign in to comment.