fix(worker+api): batch title vfb alignment, race-free config, auto-queue (3 bugs) #2097
Reference in New Issue
Block a user
Delete Branch "fix/gpu-direct-title-vfb-alignment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
staging 17:30-17:43 用户提交 6 个批量视频测试,反馈:
本 PR 一次性修复以下 3 个问题:
Fix 1: GPU 直连标题默认值对齐 CPU vfb 路径(视觉一致性)
Fix 2 (Bug A, P1): 同 plan 多任务并发渲染时 title_config 竞态覆盖
根因:
_sync_task_config_to_plan()把每个任务的 title_config/bgm/分辨率写入共享的plan.config["title"]行,RenderAdapter.render_plan()再从plan.config读取渲染;并发任务 B 写入会覆盖任务 A 已写入的值,任务 A 可能读到任务 B 的标题文字/样式。修复:
task_config_override参数贯穿render_plan → _do_render → _prepare_bgm → UnifiedRenderService_effective_config()方法:deep-copyplan.config后 merge 任务级 override(title/bgm/export)self.plan.config的位置(title/subtitle/bgm/export/TTS)改为self._effective_config()_sync_task_config_to_plan为_build_task_config_override(深拷贝 task_info,含字段归一化)+_download_voice_for_task(独立临时文件);不再写plan.configFix 3 (Bug B, P0): USER_PENDING_LIMIT=3 429 硬拒 → 自动排队
根因:批量预检查 + safe_enqueue 双重用
USER_PENDING_LIMIT=3硬拒绝,用户一次提交 6 个任务时第 4 个起 429。修复:
USER_PENDING_LIMIT: 3 → 20(软上限,反滥用兜底,支持 6-10 批量)GLOBAL_PENDING_LIMIT=20的 503 系统繁忙保护safe_enqueue_generation_task:用户级超限改为 warning 日志,仍入队;全局超限仍回滚失败批量场景排查结论
config=dict(source.config or {})深拷贝;title text/voice/cover 通过titles[]/voice_library_ids[]/cover_urls[]per-variant 覆盖;title 样式/BGM 共享(设计如此,schema 无 title_configs[])。链路正确。测试
tests/unit/test_gpu_direct_pipeline.py: 30 passedtests/unit/test_render_adapter_pure.py: 18 passed🚀 预览环境已部署
Two batch-rendering bugs found from staging logs (6-video batch 17:30-17:43): Bug A (P1) — title_config race when same plan renders concurrently: _sync_task_config_to_plan wrote each task's title_config/bgm/resolution to the shared plan.config row, then RenderAdapter.render_plan read back from plan.config during rendering. If two tasks sharing the same plan (e.g. batch retry, preview+render, retry+new) ran concurrently, Task B's write could overwrite Task A's title before Task A's ffmpeg read it, producing videos with the wrong title text/style. Fix: stop mutating plan.config in the worker render path. Introduce task_config_override threading through render_plan / _do_render / UnifiedRenderService; URS reads config via _effective_config() which does a deep-copy plan.config merged with per-task override (title/bgm/ export). _build_task_config_override builds the override dict (with field-name normalization: font_size→size, font_color→color) from task_info, and _download_voice_for_task handles voiceover download independently. plan.config is left as-authored by the API writeback; concurrent tasks no longer race on it. Files: - apps/worker/video_processing/unified_render_service.py: add override_config param + _cfg_section/_effective_config helpers; replace all render-time self.plan.config reads (title/subtitle/bgm/ export/TTS) with _effective_config(). - apps/worker/video_processing/render_adapter.py: render_plan/_do_render/ _prepare_bgm accept task_config_override, merge into bgm/export reads, forward to URS. - apps/worker/worker_app/tasks/generation.py: replace _sync_task_config_to_plan (which wrote plan.config) with _build_task_config_override + _download_voice_for_task; pass task_config_override to render_plan. Bug B (P0) — USER_PENDING_LIMIT=3 returns HTTP 429, blocks batch submit: Pre-check in create_generation_task rejected the whole batch with 429 USER_QUEUE_FULL once user had ≥3 pending tasks; UI showed 'wait ~4 min' and prevented any more submissions. Users expect to submit a batch of 6 and have them queue naturally (worker concurrency=2). Fix: - USER_PENDING_LIMIT 3→20 (soft cap for abuse protection, supports typical batch sizes of 6-10 with headroom). - Remove user-level 429 rejection from pre-check, retry endpoint, single-task confirm endpoint, and safe_enqueue (user path now logs a warning and continues to enqueue). Global GLOBAL_PENDING_LIMIT=20 is retained as a hard 503 system-busy guard. - safe_enqueue post-enqueue check: user-over only logs, does not fail the task or raise. - Batch loop UserPendingLimitExceeded except branch now treats it as a successful enqueue (should not trigger in practice). Files: - apps/api/app/core/task_enqueue.py: limit 3→20; user checks log-only. - apps/api/app/api/routes/generation_tasks.py: remove user pre-check 429; soften retry/single/batch except branches. Stacked on PR #2095/#2097 which already fixed title baseline/width-scaling and default-constant alignment with CPU video_filter_builder. Tests: - tests/unit/test_gpu_direct_pipeline.py: 30 passed - tests/unit/test_render_adapter_pure.py: 18 passed - ruff check/format clean; py_compile cleanfix(worker): align gpu-direct title defaults (size/margin/bold) with CPU vfb pathto fix(worker+api): batch title vfb alignment, race-free config, auto-queue (3 bugs)🗑️ 预览环境已清理
PR #2097 已关闭或合并,对应的预览环境已被清理。