fix(发货数据): 早上补跑一次发货同步,副本库超时重连改为逐次拉长等待

- 凌晨 01:28 同步时副本库最近一两天的订单/商品明细常未到齐,10-12 凌晨一轮写入 4,669 个只有单号、缺商品明细的包裹
  (10.10/10.11);工作平台导出为实时查询不受影响。新增每天 07:28 再拉最近 3 天,补齐商品明细。
- selectWithReconnect:副本库超时/游标失败的重试由 2 次(间隔 0.25 秒)改为 5 次,等待 2/5/10/20/30 秒,
  白天整月重跑不再因单次超时中断(单测环境不等待)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nvGZkg27YMEdhry6eiuwf
This commit is contained in:
limeng 2026-10-12 14:39:11 +08:00
parent 9f6a5f6fde
commit c8eb6e2e5f
2 changed files with 12 additions and 2 deletions

View File

@ -84,6 +84,12 @@ class Kernel extends ConsoleKernel
->dailyAt('01:28') ->dailyAt('01:28')
->withoutOverlapping(120) ->withoutOverlapping(120)
->runInBackground(); ->runInBackground();
// 凌晨副本库最近一两天的订单/商品明细常未到齐(视图、订单商品表滞后),
// 早上再拉一次最近 3 天,补齐凌晨只写入单号、缺商品明细的包裹。
$schedule->command('jushuitan:sync-shipping --days=3')
->dailyAt('07:28')
->withoutOverlapping(120)
->runInBackground();
} }
} }

View File

@ -25,7 +25,9 @@ use Throwable;
*/ */
class ShippingReplicaSynchronizer class ShippingReplicaSynchronizer
{ {
private const UPSTREAM_RECONNECT_RETRIES = 2; private const UPSTREAM_RECONNECT_RETRIES = 5;
/** 副本库繁忙超时后的重连等待(毫秒):逐次拉长,白天整月重跑不再因单次超时中断 */
private const UPSTREAM_RECONNECT_BACKOFF_MS = [2000, 5000, 10000, 20000, 30000];
private const SOURCE = 'operations_replica'; private const SOURCE = 'operations_replica';
private const DATASET = 'jst.sctrade'; private const DATASET = 'jst.sctrade';
@ -586,7 +588,9 @@ class ShippingReplicaSynchronizer
// select() returns only after fetchAll(), so no partial result was consumed. // select() returns only after fetchAll(), so no partial result was consumed.
UpstreamConnection::reset(self::SOURCE); UpstreamConnection::reset(self::SOURCE);
usleep(250000); if (! app()->runningUnitTests()) {
usleep(1000 * (self::UPSTREAM_RECONNECT_BACKOFF_MS[$retry] ?? 30000));
}
} }
} }
} }