diff --git a/internal/polling/carrierqueue/scripts.go b/internal/polling/carrierqueue/scripts.go index 7b6fb236..7aa9586a 100644 --- a/internal/polling/carrierqueue/scripts.go +++ b/internal/polling/carrierqueue/scripts.go @@ -60,7 +60,10 @@ local function tryClaim(cardId, fromPriority, qkey) end end for g, n in pairs(need) do - if budget[g] ~= nil and (used[g] or 0) + n > budget[g] then + -- 本轮该组尚未占用且预算大于 0 时至少放行一张卡:否则一张卡的调用数大于预算(如账户 1 QPS、卡同时到期 3 项)时永远领不到; + -- 超出部分由网关限流等待模式在调用时排队。 + local u = used[g] or 0 + if budget[g] ~= nil and (budget[g] <= 0 or (u > 0 and u + n > budget[g])) then stop = true return false end