From d6b223ba258bc650bd8a53508b88d9972195b8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sat, 5 Sep 2026 00:06:45 +0800 Subject: [PATCH] =?UTF-8?q?task-199:=20=E8=B6=85=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E6=9C=9F=E6=B4=BB=E8=B7=83=20job=20=E5=B7=A1=E6=A3=80=20SQL?= =?UTF-8?q?=EF=BC=8806=5Fover=5Fretention=5Factive=5Fjob.sql=EF=BC=8CRUNNI?= =?UTF-8?q?NG=20=E8=B6=8524h=20=E5=80=99=E9=80=89=EF=BC=8C=E6=B8=85?= =?UTF-8?q?=E7=90=86=E8=B5=B0=20stuck=20=E6=89=AB=E6=8F=8F=EF=BC=89+=208?= =?UTF-8?q?=20=E6=9D=A1=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../06_over_retention_active_job.sql | 18 ++++++++++++++++++ ...verRetentionActiveJobSqlInspectionTest.java | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 backend-java/src/main/resources/inspection/06_over_retention_active_job.sql create mode 100644 backend-java/src/test/java/com/nanri/aiimage/config/OverRetentionActiveJobSqlInspectionTest.java diff --git a/backend-java/src/main/resources/inspection/06_over_retention_active_job.sql b/backend-java/src/main/resources/inspection/06_over_retention_active_job.sql new file mode 100644 index 00000000..b44d16f6 --- /dev/null +++ b/backend-java/src/main/resources/inspection/06_over_retention_active_job.sql @@ -0,0 +1,18 @@ +-- ============================================================= +-- 巡检 06:超保留期仍活跃的 job(RUNNING 且 updated_at 超 24h)— 只读报表(task-199) +-- 疑似滞留/心跳丢失的 job;实际清理走 stuck 扫描(module-09),本 SQL 仅给出候选。 +-- 保留期阈值按需调整 INTERVAL;仅副本库只读执行,无副作用。 +-- ============================================================= +SELECT j.id AS job_id, + j.task_id, + j.module_type, + j.status, + j.updated_at, + t.module_type AS task_module_type, + TIMESTAMPDIFF(MINUTE, j.updated_at, NOW()) AS age_minutes +FROM biz_task_file_job j +JOIN biz_file_task t ON t.id = j.task_id +WHERE j.status = 'RUNNING' + AND j.updated_at < DATE_SUB(NOW(), INTERVAL 24 HOUR) +ORDER BY j.updated_at ASC +LIMIT 200; diff --git a/backend-java/src/test/java/com/nanri/aiimage/config/OverRetentionActiveJobSqlInspectionTest.java b/backend-java/src/test/java/com/nanri/aiimage/config/OverRetentionActiveJobSqlInspectionTest.java new file mode 100644 index 00000000..88462723 --- /dev/null +++ b/backend-java/src/test/java/com/nanri/aiimage/config/OverRetentionActiveJobSqlInspectionTest.java @@ -0,0 +1,9 @@ +package com.nanri.aiimage.config; + +/** task-199:超保留期仍活跃 job 巡检 SQL 契约。 */ +class OverRetentionActiveJobSqlInspectionTest extends InspectionSqlFileTestBase { + @Override + String fileName() { + return "06_over_retention_active_job.sql"; + } +}