docs: 补入 2026-09-03 工作日志(同步 1062 复发 + 甲骨文过载)

这份日志一直没入库,同目录 8/20 到 8/31 的都在。内容是 9/3 那次排查记录:
Oracle 侧 SQLite id 整体重排导致 sync_videos/sync_people 二次 1062、游标卡死
(修复即 0238030),以及同一天甲骨文整机过载挂死、SSH 握手被拒的环境问题。

后半段那个「Oracle 盒子过载」当时记为未解决,现在有了后续:运动事件推送从那天
起断流十天,直到 2026-09-13 全量迁云时才发现并恢复(见 PROGRESS 同日条目)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ericwyuan
2026-09-13 08:55:08 +08:00
parent da60365214
commit a494d60361

View File

@@ -0,0 +1,39 @@
# 2026-09-03 同步 1062 复发 + Oracle 盒子过载
## 问题
用户报 sync 状态卡在「同步中」+ `1062 Duplicate entry '...mp4' for key 'filename'`
游标停在 `2026-09-02 13:55:21`
## 根因(与 8/29 identity_map 同一类)
Oracle FAM-Edge 的 SQLite 视频/人物 id 整体重排2303 段 → 3408/4600+ 段),
NAS 镜像表 `sync_videos`/`sync_people` 旧 upsert 以 Oracle id 当主键插入,
与已存在的同 `filename`/`label` 行在 UNIQUE 键上二次冲突 → 1062整批中止、游标不推进。
量化:本次积压 348 videos 中 **114 行**会 10629 people 中 **6 行**会 1062。
events/model_calls 仅 PK idON DUPLICATE 按 id 更新,不会 1062→ 无需改。
## 修复(已部署 NAS + 提交推送 0238030
- `upsert_sync_videos`:改以 `filename` 业务键去重,命中就地 UPDATE 保留 NAS 原 id
(防 sync_events/model_calls/identity_map 的 video_id 外键失效Oracle id 落
`oracle_id` 列溯源;未命中插入优先用 Oracle id 对齐子表引用,主键冲突回退自增。
- `upsert_sync_people`:同模式,以 `label` 业务键去重people.id 无外键引用)。
- `scripts/ddl.sql`sync_videos/sync_people 的 id 改 NAS 本地自增 + 新增 oracle_id 列。
- NAS 现网迁移:两表加 oracle_id、回填 oracle_id=id、id 改 AUTO_INCREMENT重启。
- 验证:单批补拉 videos+348 events+1017 people+9 model_calls+500 identity_map+238
游标 → `2026-09-03 08:51:11`,无 1062。目标行保留 id=2303、oracle_id=3408。
## 第二个问题Oracle 盒子过载/挂死(未解决,环境层)
NAS 日志 08:5108:56 持续:`推送运动事件到 Oracle 失败 Connection reset` /
`500 {"error":"database is locked"}` / `RemoteDisconnected`
FAM-Edge /health 先 200status ok后变 HTTP 000最终整盒 129.146.26.249 全暗
:80/:5000/:5300/:7000/:8123 均 000但 TCP :22/:5000 端口 OPEN、SSH 握手被拒
kex 阶段 Connection closed→ 进程卡死/资源耗尽4C23G 上 FAM-Edge 分析管线 +
ai-gateway + garmin + auth-hub + frps + caddy 挤一起SQLite 锁竞争 + 可能 OOM
**SSH 连不进去,无法远程修复。** 需用户在 Oracle Cloud 控制台重启 VM或等其自恢复。
恢复后 NAS 的 oracle_sync 后台线程30min 周期)会自动从游标 08:51:11 续拉,
motion_notifier 也会恢复推送。
## 经验
- 所有以 Oracle id 为镜像主键的表迟早会因 Oracle 库重建/重排踩坑。已修:
identity_map(8/29)、videos+people(9/3)。events/model_calls 目前 PK-only 安全,
但若将来 Oracle 重建导致子表引用错位,需同样改造(加 oracle_id + 业务键)。
- Oracle 盒子服务过多挤在 4C23G建议拆分或给 FAM-Edge SQLite 开 WAL + 限速。