From 0a13eabe642d7b502f91467f6c93e54f6c9aa7a2 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 27 四月 2026 12:44:15 +0800
Subject: [PATCH] fix: release auto tune scheduler lock on guard failure

---
 src/main/java/com/zy/ai/service/impl/AutoTuneCoordinatorServiceImpl.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/ai/service/impl/AutoTuneCoordinatorServiceImpl.java b/src/main/java/com/zy/ai/service/impl/AutoTuneCoordinatorServiceImpl.java
index bbafe96..8b26ec5 100644
--- a/src/main/java/com/zy/ai/service/impl/AutoTuneCoordinatorServiceImpl.java
+++ b/src/main/java/com/zy/ai/service/impl/AutoTuneCoordinatorServiceImpl.java
@@ -82,8 +82,8 @@
         }
 
         AutoTuneAgentService.AutoTuneAgentResult agentResult = null;
-        markLastTriggerGuard(intervalMinutes);
         try {
+            safeMarkLastTriggerGuard(intervalMinutes);
             agentResult = autoTuneAgentService.runAutoTune(AutoTuneTriggerType.AUTO.getCode());
             safeWriteOperateLog(agentResult);
             return AutoTuneCoordinatorResult.triggered(agentResult);
@@ -159,6 +159,14 @@
         return System.currentTimeMillis() - latestFinishTime.getTime() >= intervalMillis;
     }
 
+    private void safeMarkLastTriggerGuard(int intervalMinutes) {
+        try {
+            markLastTriggerGuard(intervalMinutes);
+        } catch (Exception exception) {
+            log.warn("Auto tune coordinator failed to write last trigger guard", exception);
+        }
+    }
+
     private void markLastTriggerGuard(int intervalMinutes) {
         long expireSeconds = intervalMinutes * 60L;
         redisUtil.set(RedisKeyType.AI_AUTO_TUNE_LAST_TRIGGER_GUARD.key,

--
Gitblit v1.9.1