fix(acceptance): 修复快照迁移重放与派发死锁
本地同构验收在全量迁移后导入生产快照,导致本次发布的数据迁移被旧能力覆盖;增加仅允许严格本地集群标记启用的导入后迁移重放,并新增幂等 Seedance 约束校准。\n\n批量异步派发改为在事务开始按全局顺序预锁全部任务与容量作用域,同时对 PostgreSQL 死锁和序列化失败做退避重试,避免双 API 重叠批次形成环形等待。\n\n验证:Go 全量测试、gofmt、bash -n、ShellCheck、迁移安全检查。
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
-- easyai:migration:reapply-after-acceptance-import
|
||||
-- A production snapshot is imported after the local schema is migrated. Replay
|
||||
-- this idempotent catalog reconciliation so the local target state includes the
|
||||
-- data changes delivered by the release under test.
|
||||
WITH input_constraints AS (
|
||||
SELECT jsonb_build_object(
|
||||
'input_image_resolution_range',
|
||||
'{"min":{"long_edge":300,"short_edge":300},"max":{"long_edge":6000,"short_edge":6000}}'::jsonb,
|
||||
'input_image_aspect_ratio_range',
|
||||
'[0.4,2.5]'::jsonb
|
||||
) AS value
|
||||
),
|
||||
target_base_models AS (
|
||||
SELECT
|
||||
base_model.id,
|
||||
COALESCE(base_model.capabilities, '{}'::jsonb) || jsonb_build_object(
|
||||
'image_to_video',
|
||||
COALESCE(base_model.capabilities->'image_to_video', '{}'::jsonb) || input_constraints.value,
|
||||
'omni_video',
|
||||
COALESCE(base_model.capabilities->'omni_video', '{}'::jsonb) || input_constraints.value
|
||||
) AS image_capabilities
|
||||
FROM base_model_catalog base_model
|
||||
CROSS JOIN input_constraints
|
||||
WHERE base_model.provider_key = 'volces'
|
||||
AND (
|
||||
base_model.canonical_model_key IN (
|
||||
'volces:doubao-seedance-2-0-260128',
|
||||
'volces:doubao-seedance-2-0-fast-260128',
|
||||
'volces:doubao-seedance-2-0-mini-260615'
|
||||
)
|
||||
OR base_model.provider_model_name IN (
|
||||
'doubao-seedance-2-0-260128',
|
||||
'doubao-seedance-2-0-fast-260128',
|
||||
'doubao-seedance-2-0-mini-260615'
|
||||
)
|
||||
)
|
||||
),
|
||||
updated_base_models AS (
|
||||
UPDATE base_model_catalog base_model
|
||||
SET capabilities = target.image_capabilities,
|
||||
metadata = jsonb_set(
|
||||
COALESCE(base_model.metadata, '{}'::jsonb) || jsonb_build_object(
|
||||
'rawModel',
|
||||
COALESCE(base_model.metadata->'rawModel', '{}'::jsonb)
|
||||
),
|
||||
'{rawModel,capabilities}',
|
||||
target.image_capabilities - 'originalTypes',
|
||||
true
|
||||
),
|
||||
default_snapshot = CASE
|
||||
WHEN COALESCE(base_model.default_snapshot, '{}'::jsonb) = '{}'::jsonb
|
||||
THEN base_model.default_snapshot
|
||||
ELSE jsonb_set(
|
||||
jsonb_set(
|
||||
base_model.default_snapshot || jsonb_build_object(
|
||||
'metadata',
|
||||
COALESCE(base_model.default_snapshot->'metadata', '{}'::jsonb) || jsonb_build_object(
|
||||
'rawModel',
|
||||
COALESCE(base_model.default_snapshot#>'{metadata,rawModel}', '{}'::jsonb)
|
||||
)
|
||||
),
|
||||
'{capabilities}',
|
||||
target.image_capabilities,
|
||||
true
|
||||
),
|
||||
'{metadata,rawModel,capabilities}',
|
||||
target.image_capabilities - 'originalTypes',
|
||||
true
|
||||
)
|
||||
END,
|
||||
updated_at = now()
|
||||
FROM target_base_models target
|
||||
WHERE base_model.id = target.id
|
||||
RETURNING base_model.id
|
||||
)
|
||||
UPDATE platform_models platform_model
|
||||
SET capabilities = COALESCE(platform_model.capabilities, '{}'::jsonb) || jsonb_build_object(
|
||||
'image_to_video',
|
||||
COALESCE(platform_model.capabilities->'image_to_video', '{}'::jsonb) || input_constraints.value,
|
||||
'omni_video',
|
||||
COALESCE(platform_model.capabilities->'omni_video', '{}'::jsonb) || input_constraints.value
|
||||
),
|
||||
updated_at = now()
|
||||
FROM integration_platforms platform
|
||||
CROSS JOIN input_constraints
|
||||
WHERE platform_model.platform_id = platform.id
|
||||
AND platform.deleted_at IS NULL
|
||||
AND platform.provider = 'volces'
|
||||
AND (
|
||||
platform_model.base_model_id IN (SELECT id FROM updated_base_models)
|
||||
OR COALESCE(NULLIF(platform_model.provider_model_name, ''), platform_model.model_name) IN (
|
||||
'doubao-seedance-2-0-260128',
|
||||
'doubao-seedance-2-0-fast-260128',
|
||||
'doubao-seedance-2-0-mini-260615'
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user