fix(tts): AI Review 阻塞项——去除竞态处理中对 repository 内部 session 的依赖
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4m38s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m39s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 4m47s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m50s
AI Code Review / AI Code Review (pull_request) Failing after 5m53s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 7m5s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m20s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 9m13s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 9m14s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m43s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration 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
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 405h40m29s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 405h42m8s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 405h42m10s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 405h48m14s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 405h48m17s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 405h48m17s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 405h48m14s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 405h48m19s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 406h22m23s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 406h22m27s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4m38s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m39s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 4m47s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m50s
AI Code Review / AI Code Review (pull_request) Failing after 5m53s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 7m5s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m20s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 9m13s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 9m14s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m43s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration 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
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 405h40m29s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 405h42m8s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 405h42m10s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 405h48m14s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 405h48m17s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 405h48m17s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 405h48m14s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 405h48m19s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 405h48m18s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 406h22m23s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 406h22m27s
IntegrityError 后不再手动 getattr(repo, 'session').rollback(): SQLAlchemy commit 失败时 session 已自动回滚,直接重查已存在的库即可, 避免依赖 repository 内部实现(scoped_session/async session 下可能失效)。 同时 mypy:_find_or_create_voice_library 的 asset_library_repository 参数 改 Any 类型(port Protocol 声明 async、SQLAlchemy 实现为同步,与 upload/asset_libraries 路由既有惯例一致)。
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from app.auth import AuthenticatedUser, get_current_user
|
||||
from app.core.celery_app import celery_app
|
||||
@@ -309,7 +309,7 @@ def _find_or_create_voice_library(
|
||||
*,
|
||||
user_id: str,
|
||||
project_repository: ProjectRepository,
|
||||
asset_library_repository: AssetLibraryRepository,
|
||||
asset_library_repository: Any, # port Protocol 声明为 async,SQLAlchemy 实现为同步,与 upload/asset_libraries 路由惯例一致用 Any
|
||||
) -> AssetLibrary:
|
||||
"""在用户可访问的项目中找到(或自动创建)voice 素材库。
|
||||
|
||||
@@ -341,12 +341,9 @@ def _find_or_create_voice_library(
|
||||
)
|
||||
try:
|
||||
return asset_library_repository.create(library)
|
||||
except Exception as e:
|
||||
if not isinstance(e, IntegrityError):
|
||||
raise
|
||||
session = getattr(asset_library_repository, "session", None)
|
||||
if session is not None:
|
||||
session.rollback()
|
||||
except IntegrityError:
|
||||
# 并发下另一个请求已抢先创建:SQLAlchemy commit 失败后 session 会自动回滚,
|
||||
# 直接重查返回已存在的库即可(不依赖 repository 的内部 session 实现)。
|
||||
for lib in asset_library_repository.find_by_project(project.id):
|
||||
kind = lib.kind.value if hasattr(lib.kind, "value") else lib.kind
|
||||
if kind == AssetLibraryKind.VOICE.value:
|
||||
@@ -354,7 +351,7 @@ def _find_or_create_voice_library(
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail="配音素材库创建失败,请重试",
|
||||
) from e
|
||||
)
|
||||
|
||||
|
||||
@router.post(
|
||||
|
||||
@@ -88,7 +88,6 @@ class FakeAssetLibraryRepo:
|
||||
def __init__(self, libs=None, fail_integrity=False):
|
||||
self._libs = list(libs or [])
|
||||
self.fail_integrity = fail_integrity
|
||||
self.session = MagicMock()
|
||||
|
||||
def find_by_project(self, project_id):
|
||||
return [lib for lib in self._libs if lib.project_id == project_id]
|
||||
|
||||
Reference in New Issue
Block a user