fix: 停复机指令队列审查问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m24s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m24s
- 开关开启但分发器心跳缺失时回退为当场执行,避免指令无人消费 - 待确认指令先查上游状态再判断;执行期间被覆盖时把待确认带到新指令 - 同方向失败退避中重复写入不提前执行时间 - 领取容量把执行上限与本秒剩余 QPS 分开计算 - 队列复机共用单卡复机锁;执行上下文取消后按结果未知确认 - 消费者并行停止;读取最近调用时间失败时不覆盖;成功但终结日志失败按成功处理 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,29 +42,30 @@ func (d *Dispatcher) stopResumeLease() time.Duration {
|
||||
// dispatchStopResume 在卡任务之前领取账户停复机指令:领取数 = min(停复机所在限流组本秒剩余, 执行上限 − 执行中)。
|
||||
func (d *Dispatcher) dispatchStopResume(ctx context.Context, carrierID uint) {
|
||||
params := d.ParamsFor(carrierID)
|
||||
capacity := params.SRInflightLimit
|
||||
limit := params.SRInflightLimit
|
||||
processes := d.cfg.SubscriberProcesses
|
||||
if processes <= 0 {
|
||||
processes = 1
|
||||
}
|
||||
if consume := params.SRMaxInFlight * processes; consume > 0 && capacity > consume {
|
||||
capacity = consume
|
||||
if consume := params.SRMaxInFlight * processes; consume > 0 && limit > consume {
|
||||
limit = consume
|
||||
}
|
||||
budget := -1
|
||||
if d.budgets != nil {
|
||||
ops := []string{constants.GatewayOpStop, constants.GatewayOpStart}
|
||||
if groups, _, limited := d.budgets.Budget(ctx, carrierID, ops); limited {
|
||||
for _, remaining := range groups {
|
||||
if remaining < capacity {
|
||||
capacity = remaining
|
||||
if budget < 0 || remaining < budget {
|
||||
budget = remaining
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if capacity <= 0 {
|
||||
if limit <= 0 || budget == 0 {
|
||||
return
|
||||
}
|
||||
claimed, expired, err := d.store.ClaimStopResume(ctx, SRClaimInput{
|
||||
CarrierID: carrierID, Lease: d.stopResumeLease(), Capacity: capacity, MinInterval: params.SRMinInterval,
|
||||
CarrierID: carrierID, Lease: d.stopResumeLease(), InflightLimit: limit, Budget: budget, MinInterval: params.SRMinInterval,
|
||||
TokenPrefix: d.instanceID + ":sr:" + strconv.FormatInt(time.Now().UnixNano(), 36),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user