fix(backend): #1867 对口型卡running三层防御修复(rebase到最新develop) #1916

Merged
auto-approve-bot merged 5 commits from fix/1867-lipsync-triple-defense-rebased into develop 2026-09-15 03:35:30 +08:00
Owner

背景

旧PR #1867 分支基于老develop,存在大量冲突无法自动合并。本PR基于最新develop重新应用三层防御修复,保留所有已合入的lipsync优化(#1845 TTS预合成、#1849 import修复、#1864 封面/cv2依赖)。

三层防御

  1. 前端轮询层:GET /lipsync/jobs/{id} 中,若距上次更新超过30秒,同步调用 refresh_job_status(避免 FastAPI BackgroundTasks 静默失败导致前端永远看到 running),否则仍后台异步刷新
  2. DB层:refresh_job_status 中 DB commit 包 try/except 并 rollback,防止提交异常导致后续轮询链路断裂
  3. Worker层:TTS 合成并提交 MediaKit 成功后,链式触发 Celery 兜底轮询任务 poll_mediakit_status(最多60次×10秒=10分钟),不依赖前端轮询

测试

  • 本地 102 个lipsync相关单测全部通过
  • 覆盖原有lipsync_routes/lipsync_tts/lipsync_tts_preview/ai_avatar等测试

Closes #1867

## 背景 旧PR #1867 分支基于老develop,存在大量冲突无法自动合并。本PR基于最新develop重新应用三层防御修复,保留所有已合入的lipsync优化(#1845 TTS预合成、#1849 import修复、#1864 封面/cv2依赖)。 ## 三层防御 1. **前端轮询层**:GET /lipsync/jobs/{id} 中,若距上次更新超过30秒,同步调用 refresh_job_status(避免 FastAPI BackgroundTasks 静默失败导致前端永远看到 running),否则仍后台异步刷新 2. **DB层**:refresh_job_status 中 DB commit 包 try/except 并 rollback,防止提交异常导致后续轮询链路断裂 3. **Worker层**:TTS 合成并提交 MediaKit 成功后,链式触发 Celery 兜底轮询任务 poll_mediakit_status(最多60次×10秒=10分钟),不依赖前端轮询 ## 测试 - 本地 102 个lipsync相关单测全部通过 - 覆盖原有lipsync_routes/lipsync_tts/lipsync_tts_preview/ai_avatar等测试 Closes #1867
xiaoxia added 1 commit 2026-09-15 02:10:46 +08:00
fix(backend): #1867 对口型卡running三层防御修复(rebase到最新develop)
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 0s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 46s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 46s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m23s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m21s
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 37h12m40s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 37h12m48s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 37h12m53s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 37h12m13s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 37h12m14s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 37h12m15s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 37h12m19s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 37h12m19s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 37h12m20s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 37h12m27s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 37h12m7s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 37h12m8s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 37h12m21s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 37h12m21s
8092d60111
三层防御:
1. 前端轮询 GET /lipsync/jobs/{id}:距上次更新超过30秒时同步刷新一次(避免 background task 静默失败永久卡 running),否则后台异步刷新
2. refresh_job_status:DB commit 包 try/except 并 rollback,防止 DB 提交失败导致后台任务静默失败
3. TTS Celery 任务:MediaKit 提交成功后链式触发 poll_mediakit_status 兜底轮询任务(worker主动拉状态,最多60次×10s=10分钟,不依赖前端轮询)

解决冲突: rebase 到最新 develop(含 #1845/#1849/#1864 等已合并的lipsync优化),保留同步转存/异步转存/预合成等已有功能

Refs #1867

🚀 预览环境已部署

项目 详情
PR号 #1916
预览链接 https://pr-1916.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1916 | | 预览链接 | [https://pr-1916.preview.xiaoxiajianji.com](https://pr-1916.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot added 1 commit 2026-09-15 02:15:02 +08:00
style: auto-format with black + isort + ruff + prettier [skip ci-format-check]
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m22s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m26s
AI Code Review / AI Code Review (pull_request) Successful in 6m30s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 5m12s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m54s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m59s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 3m30s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m42s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 3m44s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 8m8s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 9m51s
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Failing after 36h43m17s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 36h52m57s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 36h53m7s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 36h53m11s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 36h52m57s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 36h53m7s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 36h53m8s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 36h52m38s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 36h52m38s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 36h52m39s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 36h52m39s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 36h42m46s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 36h42m46s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 36h52m25s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 36h52m30s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 36h42m45s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 36h52m35s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 37h18m16s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 37h28m9s
425018ecc0
xiaoxia added 1 commit 2026-09-15 02:58:01 +08:00
test(#1867): 补充三层防御单测提覆盖率到 CI 阈值
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 39s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m11s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m54s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m46s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 4m15s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 4m13s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 4m29s
AI Code Review / AI Code Review (pull_request) Successful in 6m31s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 6m35s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 10m41s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 5s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 7m51s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 36h14m52s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 36h25m23s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 36h25m35s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 36h25m36s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 36h24m56s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 36h24m57s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 36h25m2s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 36h25m4s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 36h25m10s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 36h14m23s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 36h14m23s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 36h14m23s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 36h14m19s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 36h24m50s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 36h24m50s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 36h24m57s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 36h25m4s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 36h25m4s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 37h0m28s
4c4d4b76c5
- Layer 1 (routes): stale>30s 同步刷新 / fresh 后台刷新 / completed 跳过 /
  同步异常 fallback 到 background / 404 共 5 个分支
- Layer 2 (service): DB commit 异常 rollback + 中间态 commit + failed 写
  error_info 共 3 个分支
- Layer 3 (worker): poll_mediakit_status 新任务 10 个分支 (not found /
  终态跳过 / 无 mk_task_id / succeeded→completed+persist / persist 失败回退
  temp_url / failed / error / running→retry) + tts 提交成功链式触发 poll
  3 个分支 (成功 dispatch / 失败不 dispatch / dispatch 异常不影响主流程)
- 共 21 个新测试,全量 15126 passed。

[skip ci-format-check]
xiaoxia added 1 commit 2026-09-15 03:12:37 +08:00
style(#1867): isort 修复 test_lipsync_routes 导入顺序
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 39s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 41s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m10s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m42s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 3m51s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m51s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m13s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m26s
AI Code Review / AI Code Review (pull_request) Successful in 6m31s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 8m57s
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m41s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 36h2m3s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 36h10m53s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 36h11m3s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 36h11m5s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 36h10m25s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 36h10m30s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 36h10m30s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 36h10m30s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 36h10m32s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 36h10m32s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 36h10m34s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 36h1m32s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 36h1m32s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 36h10m20s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 36h1m29s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 36h10m20s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 36h10m31s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 36h10m31s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 36h37m3s
cd087f272b
[skip ci-format-check]
xiaoxia added 1 commit 2026-09-15 03:25:41 +08:00
fix(#1867): B904 raise-without-from 合规(Celery retry 异常链)
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 39s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 39s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m8s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m52s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m59s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 3m44s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 5m42s
AI Code Review / AI Code Review (pull_request) Successful in 6m29s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 7m13s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 9m6s
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 6m53s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 18s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 41s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 35h48m51s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 35h57m56s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 35h57m57s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 35h58m3s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 35h57m23s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 35h57m23s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 35h57m23s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 35h57m29s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 35h57m29s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 35h57m30s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 35h48m19s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 35h48m19s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 35h57m12s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 35h57m18s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 35h48m18s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 35h48m19s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 35h57m12s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 35h57m24s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 36h32m43s
85832396d5
- 两个 raise self.retry(exc=exc) 追加 from exc 满足 ruff B904 规则
auto-approve-bot merged commit 695a491c5d into develop 2026-09-15 03:35:30 +08:00
auto-approve-bot deleted branch fix/1867-lipsync-triple-defense-rebased 2026-09-15 03:35:30 +08:00

🗑️ 预览环境已清理

PR #1916 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1916 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.