chore(retry): 新增 SMS 限流重试的库侧脚本(MA:0038 映射 + 普通类阶梯)
resources/sql 下两份手工执行迁移脚本(供 DBA 在目标库运行,均幂等):
- provider-error-code-mapping/telecom_sms_MA0038_retryable.sql:
给 push_provider_error_code_mapping 配 (telecom,sms,MA:0038 ->
unified_error_code=RATE_LIMIT, should_retry=1)。与 TelecomSmsSender
的 status=6 改动(c892f71)缺一不可——MA:0038 才能进重试链并被识别为限流类。
- sms_retry_strategy_ladder.sql:
普通类 sms 失败重试阶梯 retry_intervals='60,120,300,600'、max_retry_count=6
(TD-3 决策),取代旧 quickfix 的 60s 平铺;限流类由代码 120s/12h 保证,不读此表。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
-- ============================================================================
|
||||||
|
-- 电信短信「短期频繁发送」限流码 MA:0038 配置为可重试
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
-- 背景:电信下行回执查询(action=select)对该类消息返回 status=6 / stat=MA:0038。
|
||||||
|
-- 1) 代码侧已在 TelecomSmsSender.getDownInfo 把 status=6 纳入失败映射分支;
|
||||||
|
-- 2) 本脚本在错误码映射表为 MA:0038 配置 should_retry=1,
|
||||||
|
-- 使其经 Sender.buildFailureResult 判定为 RETRYABLE_FAILED,进入重试队列。
|
||||||
|
-- 两者缺一不可。SMS 首次重试间隔默认 5 分钟,足以越过服务商 1 分钟限流窗口。
|
||||||
|
--
|
||||||
|
-- 该脚本幂等:已存在同 (provider_type, channel, original_code) 的有效记录时不重复插入。
|
||||||
|
-- ============================================================================
|
||||||
|
INSERT INTO push_provider_error_code_mapping
|
||||||
|
(provider_type, channel, original_code, original_message,
|
||||||
|
unified_error_code, unified_error_message, error_category,
|
||||||
|
should_retry, final_status, remark,
|
||||||
|
creator, updater, create_time, update_time, deleted)
|
||||||
|
SELECT
|
||||||
|
'telecom', 'sms', 'MA:0038', '短期频繁发送',
|
||||||
|
'RATE_LIMIT', '服务商短期频繁发送限流', 'PROVIDER_ERROR',
|
||||||
|
1, 'retryable_failed', '电信限流码,需自动重试',
|
||||||
|
'system', 'system', NOW(), NOW(), 0
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM push_provider_error_code_mapping
|
||||||
|
WHERE provider_type = 'telecom'
|
||||||
|
AND channel = 'sms'
|
||||||
|
AND original_code = 'MA:0038'
|
||||||
|
AND deleted = 0
|
||||||
|
);
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
-- ============================================================================
|
||||||
|
-- 普通类短信失败的重试阶梯配置(rootfix 后)
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
-- 背景:限流类(电信 MA:0038)已由代码硬编码 120s 间隔 + 12h 兜底,忽略本表。
|
||||||
|
-- 故 push_retry_strategy_config.retry_intervals 现仅作用于「普通类」sms 可
|
||||||
|
-- 重试失败(超时 / 通道故障 / 第三方调用失败等),与限流类无关。
|
||||||
|
--
|
||||||
|
-- 决策(TD-3,2026-06-20):普通类用收紧的阶梯退避,替代旧 quickfix 的 60s 平铺。
|
||||||
|
-- retry_intervals = '60,120,300,600' → 1→2→5→10 分钟,超出后按 10 分钟重复
|
||||||
|
-- max_retry_count = 6 → 第 6 次普通失败转 final_failed(约 28 分钟放弃)
|
||||||
|
--
|
||||||
|
-- 幂等:可重复执行。⚠ retry_intervals 不能含空格(代码 Long.parseLong 不容忍空格)。
|
||||||
|
-- 关系:本文件取代 sms_ratelimit_retry_quickfix.sql 的 ② 段;
|
||||||
|
-- ① 错误码映射见 provider-error-code-mapping/telecom_sms_MA0038_retryable.sql。
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- 1) 已存在启用中的 sms 策略行 → 覆盖为新阶梯
|
||||||
|
-- (同时纠正 max_retry_count,覆盖旧 quickfix 写入的 '60' / max 10)
|
||||||
|
UPDATE push_retry_strategy_config
|
||||||
|
SET retry_intervals = '60,120,300,600',
|
||||||
|
max_retry_count = 6,
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE channel = 'sms'
|
||||||
|
AND enabled = 1
|
||||||
|
AND deleted = 0;
|
||||||
|
|
||||||
|
-- 2) 没有启用中的 sms 策略行 → 插一条(否则代码回落硬编码 300/600/1800、max 5)
|
||||||
|
INSERT INTO push_retry_strategy_config
|
||||||
|
(channel, max_retry_count, retry_intervals, enabled,
|
||||||
|
creator, updater, create_time, update_time, deleted)
|
||||||
|
SELECT 'sms', 6, '60,120,300,600', 1,
|
||||||
|
'system', 'system', NOW(), NOW(), 0
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM push_retry_strategy_config
|
||||||
|
WHERE channel = 'sms'
|
||||||
|
AND enabled = 1
|
||||||
|
AND deleted = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
-- 执行后自检(可选):确认普通类阶梯已就位
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
-- SELECT channel, max_retry_count, retry_intervals, enabled
|
||||||
|
-- FROM push_retry_strategy_config
|
||||||
|
-- WHERE channel = 'sms' AND enabled = 1 AND deleted = 0;
|
||||||
Reference in New Issue
Block a user