補強 cache best-effort 診斷
All checks were successful
CD Pipeline / deploy (push) Successful in 56s

This commit is contained in:
OoO
2026-05-13 11:04:34 +08:00
parent 8a36856171
commit 5b52af9e2f
2 changed files with 9 additions and 2 deletions

View File

@@ -22,6 +22,7 @@
- OpenClaw Bot中文字型下載、趨勢同期 DB 查詢、匯入格式業績預覽解析等 best-effort 區塊已補 debug/exception/warnings避免真正錯誤完全無跡可查。
- Telegram polling bot舊 callback 正規化失敗、空 `momo:eig:` event_id 回覆失敗仍保持 fail-safe但已補 debug log。
- `ai_call_logger._write_to_db` 不是死函數:它是 `_async_write()` 的 daemon thread targetdecorator token 自動抽取與 stack caller 推斷的 best-effort 失敗也已補 debug log。
- `cache_manager.FingerprintCache` 與 dashboard shared cache 清理維持 fail-open / best-effort但已補 debug log避免 cache fingerprint 或檔案清理失敗完全沉默。
## 已驗證為已修或過期
@@ -83,3 +84,4 @@
- `89c400d` 補上 OpenClaw best-effort 區塊紀錄
- `ec5a22d` 記錄 Telegram pending action 驗證
- `f44c429` 補強 AI logger best-effort 診斷
- `8a36856` 補強 Telegram callback 診斷

View File

@@ -8,10 +8,14 @@ module-level cache 收斂到這裡,避免各 route 各自持有一份 dict。
"""
import os
import logging
import time
from pathlib import Path
logger = logging.getLogger(__name__)
class FingerprintCache:
"""TTL + fingerprint 的小型 in-memory cache。"""
@@ -30,13 +34,14 @@ class FingerprintCache:
if self._fp_fn() != entry['fp']:
return None
except Exception:
pass
logger.debug("cache fingerprint check failed for %s", self.name, exc_info=True)
return entry['data']
def set(self, key, data):
try:
fp = self._fp_fn()
except Exception:
logger.debug("cache fingerprint write failed for %s", self.name, exc_info=True)
fp = None
self._store[key] = {'data': data, 'ts': time.time(), 'fp': fp}
@@ -137,4 +142,4 @@ def clear_dashboard_cache():
except FileNotFoundError:
pass
except OSError:
pass
logger.debug("dashboard shared cache cleanup failed", exc_info=True)