Commit 07bc2845 by luoqi

feat(sync): 增量摄入提频至每 2 小时 — cron 0,8-22/2 + 空轮短路

方案 A 落地(jvs-dw):
- incremental_cron: '15 0,8-22/2 * * *'(08:15~22:15 每 2h + 过天 00:15;
  cron 小时域无 24,'0' 即用户说的"24点"次日凌晨轮)
- 空轮短路:transactionsWritten=0 且 patientsUpserted=0 → 跳过 persona/org-tree/plan,
  空轮成本收敛到每表一条 cursor 探查(秒级)。条件保守:患者主档变化不产事务但进画像,不跳。

背景:DW 当前每日 08:00 一批(实测 13:56 时三表 updated_date 仍停昨日 23 点),
日内轮询换来的是 ① DW 迟到/失败当天自愈(原等 24h)② 手动补摄自动收口
③ 瑞尔 DW 计划提频 2h,PAC 先就绪。防重前提已具备:并发锁 + cursor 幂等 + 同行去重。
计划重算链路不动(空轮短路后不会被空跑)。

验证:cron 库实测 next 14 次触发序列正确;manifest 解析 auto_sync/cron 正常;tsc 干净。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
parent 6dd7aefa
Pipeline #3410 failed in 0 seconds
......@@ -41,7 +41,11 @@ display_name: 瑞尔集团 DW(单 host 多 brand)
auto_sync: true # 纳入每日自动增量同步(scheduler 自动发现;取代 PAC_INCREMENTAL_HOSTS env)
# 每宿主运维配置(多宿主:上游节奏/SLA 各异,不用全局 env 一刀切)。
incremental_cron: '15 8 * * *' # 瑞尔 DW 每日 08:00(沪)落库,其后跑;按下方 timezone 解释
# 2026-07 提频:每 2h 轮询(00:15 + 08:15~22:15)。DW 当前每日 08:00(沪)一批,
# 日内多为空轮(scheduler 空轮短路,秒级);意义:① DW 迟到/失败当天自愈(原要等24h)
# ② 白天手动补摄/修数自动收口 ③ 瑞尔 DW 计划提频到 2h,PAC 先就绪零改动。
# 注:cron 小时域 0-23,"24点"即次日 0 点 → 用 '0,8-22/2' 表达 00:15 过天轮。
incremental_cron: '15 0,8-22/2 * * *' # 按下方 timezone(Asia/Shanghai)解释
monitoring:
dw_lag_warn_hours: 24 # 增量游标滞后 >24h 提醒
dw_lag_error_hours: 48 # >48h 告警(事件可能漏召)
......
......@@ -113,6 +113,18 @@ export class SyncIncrementalSchedulerService implements OnModuleInit {
`facts(created=${r.totals.factsCreated} superseded=${r.totals.factsSuperseded})`,
);
// ─── 空轮短路(2h 提频配套)──────
// DW 每日一批 → 日内轮询多为空轮;没摄到任何数据时 persona/org-tree/plan 全跳,
// 空轮成本收敛到"每表一条 cursor 探查"(秒级)。条件保守:患者主档或事务任一有
// 变化都算有数据(patient-only 变化不产事务,但会进画像,不能跳)。
if (r.totals.transactionsWritten === 0 && r.totals.patientsUpserted === 0) {
this.logger.log(
`sync-incremental: host=${r.hostName} 空轮(0 新数据),跳过 persona/org-tree/plan ` +
`(elapsed=${Date.now() - started}ms)`,
);
return;
}
// ─── Persona recompute(affected patient only)──────
if (r.syncLogId) {
const syncLog = await this.prisma.syncLog.findUnique({ where: { id: r.syncLogId } });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment