Skip to content

Commit

Permalink
fix(backend): 数据校验定时任务修复 #4996
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud authored and jinquantianxia committed Jun 20, 2024
1 parent cc50737 commit 65d27e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions dbm-ui/backend/ticket/builders/mysql/mysql_data_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ class MySQLDataRepairFlowBuilder(BaseMySQLTicketFlowBuilder):
serializer = MySQLDataRepairDetailSerializer
inner_flow_builder = MySQLDataRepairFlowParamBuilder
inner_flow_name = _("数据修复执行")
default_need_itsm = False
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ class TendbDataRepairFlowBuilder(BaseTendbTicketFlowBuilder):
serializer = TendbDataRepairDetailSerializer
inner_flow_builder = TendbDataRepairFlowParamBuilder
inner_flow_name = _("Tendb Cluster 数据修复执行")
default_need_itsm = False
8 changes: 5 additions & 3 deletions dbm-ui/backend/ticket/tasks/ticket_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ def auto_create_data_repair_ticket(cls):
# 例行时间校验默认间隔一天
now = datetime.now(timezone.utc)
start_time, end_time = now - timedelta(days=1), now
# TODO: 目前这个esquery_search最多支持10000条查询,后续可以改造成scroll进行查询
resp = BKLogApi.esquery_search(
{
"indices": f"{env.DBA_APP_BK_BIZ_ID}_bklog.mysql_checksum_result",
"start_time": datetime2str(start_time),
"end_time": datetime2str(end_time),
"query_string": "*",
"start": 0,
"size": 1000,
"size": 10000,
"sort_list": [["dtEventTimeStamp", "asc"], ["gseIndex", "asc"], ["iterationIndex", "asc"]],
}
)
Expand Down Expand Up @@ -187,8 +188,8 @@ def auto_create_data_repair_ticket(cls):
"is_ticket_consistent": False,
"checksum_table": MYSQL_CHECKSUM_TABLE,
"trigger_type": MySQLDataRepairTriggerMode.ROUTINE.value,
"start_time": start_time,
"end_time": end_time,
"start_time": datetime2str(start_time),
"end_time": datetime2str(end_time),
"infos": [
{
"cluster_id": cluster_id,
Expand All @@ -203,6 +204,7 @@ def auto_create_data_repair_ticket(cls):
ticket_type = TicketType.TENDBCLUSTER_DATA_REPAIR
cls._create_ticket(
ticket_type=ticket_type,
# TODO: 这里可以设置一个自动提单人,但是todo确认可以增加DBA
creator=cluster.creator,
bk_biz_id=cluster.bk_biz_id,
remark=_("集群{}存在数据不一致,自动创建的数据修复单据").format(cluster.name),
Expand Down

0 comments on commit 65d27e9

Please sign in to comment.