Skip to content

Commit

Permalink
fix: 修复主从迁移元数据bug TencentBlueKing#8475
Browse files Browse the repository at this point in the history
  • Loading branch information
zfrendo committed Dec 9, 2024
1 parent 1accc65 commit 228cd7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 4 additions & 2 deletions dbm-ui/backend/db_meta/api/cluster/tendbha/storage_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ def remove_storage_tuple(master_ip: str, slave_ip: str, bk_cloud_id: int, port_l


@transaction.atomic
def update_storage_tuple(master_ip: str, new_master_ip: str, bk_cloud_id: int, port_list: list):
def update_storage_tuple(master_ip: str, new_master_ip: str, exclude_ip: list, bk_cloud_id: int, port_list: list):
for port in port_list:
master_storage = StorageInstance.objects.get(
machine__ip=master_ip, port=port, machine__bk_cloud_id=bk_cloud_id
)
new_master_storage = StorageInstance.objects.get(
machine__ip=new_master_ip, port=port, machine__bk_cloud_id=bk_cloud_id
)
StorageInstanceTuple.objects.filter(ejector=master_storage).update(ejector=new_master_storage)
StorageInstanceTuple.objects.filter(ejector=master_storage).exclude(
receiver__machine__ip__in=exclude_ip
).update(ejector=new_master_storage)
10 changes: 1 addition & 9 deletions dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,18 +537,10 @@ def mysql_migrate_cluster_switch_storage(self):
api.cluster.tendbha.storage_tuple.update_storage_tuple(
master_ip=self.cluster["old_master_ip"],
new_master_ip=self.cluster["new_master_ip"],
exclude_ip=[self.cluster["old_master_ip"], self.cluster["old_slave_ip"]],
bk_cloud_id=self.cluster["bk_cloud_id"],
port_list=[self.cluster["mysql_port"]],
)
# add new slave 对应关系
# if self.cluster.get("new_ro_slave_ips"):
# for new_ro_slave_ip in self.cluster["new_ro_slave_ips"]:
# api.cluster.tendbha.storage_tuple.add_storage_tuple(
# master_ip=self.cluster["new_master_ip"],
# slave_ip=new_ro_slave_ip,
# bk_cloud_id=self.cluster["bk_cloud_id"],
# port_list=[self.cluster["master_port"]],
# )

def mysql_migrate_cluster_add_tuple(self):
"""
Expand Down

0 comments on commit 228cd7d

Please sign in to comment.