fix(fulfillment): 履约回填改用 keyset 分页并补充待回填部分索引

- 迁移 108:order_items (id) WHERE fulfillment_mode IS NULL 部分索引
  生产已 CONCURRENTLY 预建;取 5000 条待回填 id 4.8s → 4.9ms
- reconcilePendingFulfillmentModes 增加 afterId / lastScannedId,批内固定 id > 游标
- 新增 resolveReconcileCursor:游标单调前进,未前进或不足一批即结束
- backfill-fulfillment-mode 支持 --afterId 断点续跑
This commit is contained in:
yml2213
2026-10-29 15:10:28 +08:00
parent 16b62a8e6d
commit fba0a13d44
4 changed files with 126 additions and 15 deletions
@@ -9,6 +9,7 @@ import {
const options = parseOptions(process.argv.slice(2))
const batchSize = normalizeInteger(options.batchSize, 5000, 1, 50_000)
const maxBatches = normalizeInteger(options.maxBatches, 1000, 1, 10_000)
const afterId = normalizeInteger(options.afterId, 0, 0, Number.MAX_SAFE_INTEGER)
async function main() {
const column = await query<{ exists: boolean }>(
@@ -32,6 +33,7 @@ async function main() {
batchSize,
maxBatches,
reason: 'backfill_2026_10_23',
afterId,
})
const counts = await getFulfillmentModeCounts()