Files
easyai-ai-gateway/apps/api/migrations/0106_route_probe_leases.sql
T
wangbo 335b21d1f8 fix(routing): 避免路由探测耗尽数据库连接
将跨实例探测协调从持有会话级 advisory lock 改为带过期时间的数据库短租约,避免网络探测期间占用关键 PostgreSQL 连接。新增可配置的探测并发上限和真实 PostgreSQL 回归测试,确保租约生效期间连接池仍可全部获取。\n\n验证:go test ./... -count=1;go vet ./...;真实 PostgreSQL 17 集成测试;迁移安全检查。
2026-08-05 23:13:32 +08:00

12 lines
448 B
SQL

CREATE TABLE IF NOT EXISTS gateway_route_probe_leases (
pool_id text NOT NULL REFERENCES gateway_execution_pools(pool_id) ON DELETE CASCADE,
route_profile_key text NOT NULL,
lease_token uuid NOT NULL,
expires_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (pool_id, route_profile_key)
);
CREATE INDEX IF NOT EXISTS idx_gateway_route_probe_leases_expiry
ON gateway_route_probe_leases(expires_at);