将 River 执行容量按平台模型与用户组的有效并发策略动态调整,并为长任务续租、并发租约原子抢占和限流退避补充保护。\n\n统一平台模型限流继承语义,兼容历史 platformLimits/modelLimits,并为三个迁移图像模型建立独立并发租约。补充管理端显式继承/覆盖配置、指标、单元测试及隔离 PostgreSQL 验收。\n\n验证:go test ./... -count=1;pnpm lint;pnpm test;pnpm build;隔离 PostgreSQL 并发原子性/续租测试;128 任务与三分钟长任务动态 Worker 验收。
45 lines
1.6 KiB
SQL
45 lines
1.6 KiB
SQL
-- The three migrated image identities previously relied on a global
|
|
-- user-group limit. Give every upstream binding its own canonical concurrency
|
|
-- lease so raising the service group no longer removes provider protection.
|
|
WITH limits(invocation_name, policy) AS (
|
|
VALUES
|
|
(
|
|
'gemini-3-pro-image',
|
|
'{"rules":[{"metric":"concurrent","limit":10,"leaseTtlSeconds":600}]}'::jsonb
|
|
),
|
|
(
|
|
'gemini-3.1-flash-image',
|
|
'{"rules":[{"metric":"concurrent","limit":10,"leaseTtlSeconds":600}]}'::jsonb
|
|
),
|
|
(
|
|
'gpt-image-2',
|
|
'{"rules":[{"metric":"concurrent","limit":5,"leaseTtlSeconds":300}]}'::jsonb
|
|
)
|
|
),
|
|
updated_base_models AS (
|
|
UPDATE base_model_catalog base_model
|
|
SET default_rate_limit_policy = limits.policy,
|
|
metadata = COALESCE(base_model.metadata, '{}'::jsonb) || jsonb_build_object(
|
|
'rateLimitSource', 'image-gateway-migration',
|
|
'rateLimitUpdatedAt', '2026-07-24'
|
|
),
|
|
updated_at = now()
|
|
FROM limits
|
|
WHERE base_model.invocation_name = limits.invocation_name
|
|
RETURNING base_model.id
|
|
)
|
|
UPDATE platform_models platform_model
|
|
SET rate_limit_policy = '{}'::jsonb,
|
|
rate_limit_policy_mode = 'inherit',
|
|
updated_at = now()
|
|
FROM updated_base_models base_model
|
|
WHERE platform_model.base_model_id = base_model.id
|
|
AND (
|
|
platform_model.rate_limit_policy = '{}'::jsonb
|
|
OR platform_model.rate_limit_policy = '{"rules":[]}'::jsonb
|
|
OR platform_model.rate_limit_policy ? 'platformLimits'
|
|
OR platform_model.rate_limit_policy ? 'modelLimits'
|
|
OR platform_model.rate_limit_policy ? 'platform_limits'
|
|
OR platform_model.rate_limit_policy ? 'model_limits'
|
|
);
|