fix: retain async holds for unknown provider outcomes
This commit is contained in:
1 parent
76265845dc
commit
5be06a97c1
18 files changed
+574
-108
No files matched your search
@@ -157,15 +157,17 @@ public class UsageAuditService {
|
||||
WITH pending AS (
|
||||
SELECT model_id,
|
||||
COUNT(*) FILTER (WHERE status='running') AS running,
|
||||
COUNT(*) FILTER (WHERE status='queued') AS queued
|
||||
FROM model_tasks WHERE status IN ('queued','running') GROUP BY model_id
|
||||
COUNT(*) FILTER (WHERE status='queued') AS queued,
|
||||
COUNT(*) FILTER (WHERE status='reconciling') AS reconciling
|
||||
FROM model_tasks WHERE status IN ('queued','running','reconciling') GROUP BY model_id
|
||||
)
|
||||
SELECT m.id, m.public_name, m.source_label, p.name AS provider_name, m.call_mode,
|
||||
CASE WHEN m.max_concurrency = 0 THEN 0
|
||||
ELSE COALESCE(m.max_concurrency, ?) END AS max_concurrency,
|
||||
(m.status='active' AND m.deleted_at IS NULL AND p.status='active' AND p.deleted_at IS NULL
|
||||
AND d.status='active' AND d.deleted_at IS NULL) AS route_enabled,
|
||||
COALESCE(pending.running, 0) AS running, COALESCE(pending.queued, 0) AS queued
|
||||
COALESCE(pending.running, 0) AS running, COALESCE(pending.queued, 0) AS queued,
|
||||
COALESCE(pending.reconciling, 0) AS reconciling
|
||||
FROM model_catalog m JOIN model_providers p ON p.id=m.provider_id
|
||||
JOIN model_definitions d ON d.id=m.logical_model_id
|
||||
LEFT JOIN pending ON pending.model_id=m.id
|
||||
@@ -182,6 +184,7 @@ public class UsageAuditService {
|
||||
group.put("limit", modelGuardEnabled ? rs.getInt("max_concurrency") : 0);
|
||||
group.put("running", rs.getLong("running"));
|
||||
group.put("queued", rs.getLong("queued"));
|
||||
group.put("reconciling", rs.getLong("reconciling"));
|
||||
return group;
|
||||
}, defaultModelLimit);
|
||||
List<String> synchronousIds = groups.stream().filter(group -> !"async".equals(group.get("mode"))).map(group -> group.get("id").toString()).toList();
|
||||
@@ -193,12 +196,13 @@ public class UsageAuditService {
|
||||
group.put("running", current == null ? null : current.running());
|
||||
group.put("queued", current == null ? null : current.queued());
|
||||
}
|
||||
// Keep disabled groups visible while their queued or running work still exists.
|
||||
// Keep disabled groups visible while any work or unresolved financial hold still exists.
|
||||
groups = groups.stream().filter(group -> Boolean.TRUE.equals(group.get("routeEnabled"))
|
||||
|| positive(group.get("running")) || positive(group.get("queued"))).toList();
|
||||
|| positive(group.get("running")) || positive(group.get("queued")) || positive(group.get("reconciling"))).toList();
|
||||
result.put("capacityGroups", groups);
|
||||
result.put("running", totalCapacity(groups, "running"));
|
||||
result.put("waiting", totalCapacity(groups, "queued"));
|
||||
result.put("reconciling", totalCapacity(groups, "reconciling"));
|
||||
result.put("capacityConfig", Map.of(
|
||||
"queueWaitMs", gatewayGuard == null ? 30000 : gatewayGuard.queueWaitMs(),
|
||||
"defaultModelConcurrency", defaultModelLimit,
|
||||
|
||||
Reference in new issue
Block a user