跳到內容
主控台

12/13 TREM Lite 地震報告重複推送說明

嚴重程度:中狀態:已結案
發生時間
2025/12/13 03:33 (UTC+8) 左右
觸發條件
維護過程中
問題描述
TREM Lite 地震報告重複推送的問題
根本原因
快取鍵衝突

2025/12/13 03:33(臺灣時間)左右,TREM Lite 重複推送地震報告,約 22 分鐘後緩解。我們向收到重複地震報告的 TREM Lite 使用者道歉。

時間 (UTC+8)

  1. 嚴重

    TREM Lite 地震報告重複推送

  2. 取證

    確認問題,開始修復

  3. 修正

    緊急處理,試著緩解

  4. 已恢復

    觀察到問題緩解

維護 TNN Core Server 時,我們調整 Nginx 設定,重啟了 report server 容器,接著就出現重複推送。

故障時,cache_1s.inc 的 proxy_cache_key $url 蓋過 location 裡的 proxy_cache_key $cache_key。

終端機視窗
location ~ ^/api/(v1|v2)/eq/report {
set $cache_key "$uri|$arg_limit|$arg_page|$arg_minIntensity|$arg_maxIntensity|$arg_minMagnitude|$arg_maxMagnitude|$arg_minDepth|$arg_maxDepth";
proxy_pass http://report;
proxy_cache_key $cache_key;
include /etc/nginx/conf.d/cache_1s.inc;
}

cache_1s.inc

終端機視窗
proxy_cache my_cache;
proxy_cache_key $url;
proxy_cache_valid 200 1s;
proxy_cache_lock on;
proxy_cache_lock_timeout 1s;
proxy_cache_use_stale updating error timeout http_500 http_502 http_503 http_504;
proxy_cache_background_update on;

有查詢參數和沒有查詢參數的請求,$url 可能得到同一個快取鍵,例如 /api/v1/eq/report 和 /api/v1/eq/report?limit=10。兩種請求共用同一份快取,客戶端拿到的地震報告跟參數不符,同一起地震事件因此重複推送。

拿掉 cache_1s.inc 裡的 proxy_cache_key $url,快取鍵只留 location 裡的 $cache_key。這個鍵帶有查詢參數,有參數和沒參數的請求會分開存。

終端機視窗
location ~ ^/api/(v1|v2)/eq/report {
set $cache_key "$uri|$arg_limit|$arg_page|$arg_minIntensity|$arg_maxIntensity|$arg_minMagnitude|$arg_maxMagnitude|$arg_minDepth|$arg_maxDepth";
proxy_pass http://report;
proxy_cache_key $cache_key;
include /etc/nginx/conf.d/cache_1s.inc;
}

cache_1s.inc(修改後)

終端機視窗
proxy_cache my_cache;
# 移除 proxy_cache_key $url; 避免與 location 區塊中的設定衝突
proxy_cache_valid 200 1s;
proxy_cache_lock on;
proxy_cache_lock_timeout 1s;
proxy_cache_use_stale updating error timeout http_500 http_502 http_503 http_504;
proxy_cache_background_update on;

地震報告 API 目前的快取與參數規則,見文件的地震報告。