fix: 必剪转写实例复用导致的上传状态残留与并发竞争#422
Open
pumpkinperson996 wants to merge 1 commit into
Open
Conversation
BcutTranscriber 被 transcriber_provider 缓存复用,但 __etags 等上传 会话状态只在 __init__ 清空、每次上传只追加,导致容器启动后第二次 及以后的转写提交的 etag 数与分片数不符,B 站返回"第三方服务异常"。 并发提交多个视频时,多个后台任务还会在同一实例上交错上传,etag 互相混入。 - _upload() 开头重置全部上传会话状态,修串行残留 - transcript() 加实例锁,整个转写会话串行执行,修并发交错 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
BcutTranscriber实例被transcriber_provider缓存复用,但上传会话状态(__etags、__upload_id等)只在__init__时初始化,__upload_part()只做追加。后果:_upload,分片上传日志互相穿插,一个视频的 etag 混入另一个视频的提交。修复
_upload()开头重置全部上传会话状态(__etags、__in_boss_key、__resource_id、__upload_id、__upload_urls、__download_url)transcript()加threading.Lock,整个"上传→提交→建任务→轮询结果"会话持锁串行执行。并发转写会排队;如需并发吞吐,后续可考虑改为每任务独立实例测试
新增
backend/tests/test_bcut_state_reset.py:mock 必剪三步接口,同一实例连续上传 1 分片与 2 分片文件,断言第二次提交的 Etags 数量为 2(修复前为 3)。已在 Docker 镜像环境通过,并实测并发提交两个视频均转写成功。🤖 Generated with Claude Code