Repository navigation
Conversation
…failing statsig fetches
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景与目标
在排查大规模账号池后台重试与上游高频请求问题时,发现两处与 #1109 相互独立的重试风暴点:
quotarecovery.Service.runOne在探测返回终态错误(account.ErrNotFound、repository.ErrNotFound、provider.ErrUnauthorized)时未AckQuotaRecovery,而是继续按退避无限重排;对于携带RetryAfterDuration()的临时错误也未尊重更长的RetryAfter。AccountRepository.ListDueQuotaWindows与ListQuotaRecoveryWindows未关联provider_accounts过滤enabled = true AND auth_status = 'active',导致即使恢复队列 ack 了失效/停用账号,每分钟一次的reconcileDue或服务重启仍会将其重新入队。grok-site-verification时,statsigSigner.Sign未记录失败冷却窗口,每个并发后的新请求都会立刻重新抓取上游页面并打印web_statsig_fetch_failed警告日志。本 PR 基于
main独立提交,与 #1109 无文件冲突,可按任意顺序合并。主要变更
backend/internal/application/quotarecovery/service.goisTerminalQuotaRecoveryError:对account.ErrNotFound、repository.ErrNotFound、provider.ErrUnauthorized直接AckQuotaRecovery,终止无效重排。max(s.backoff(value.Attempts), provider.ErrorRetryAfter(probeErr)),尊重上游/出口层返回的冷却时间。backend/internal/infra/persistence/relational/account_repository.goListDueQuotaWindows与ListQuotaRecoveryWindows增加JOIN provider_accounts,仅返回enabled = true AND auth_status = 'active'账号的额度窗口,防止已停用或待重登账号被reconcileDue/ 启动恢复重新入队。backend/internal/infra/provider/web/statsig.gostatsigSigner增加按签名键粒度的指数失败退避(5s -> 10s -> ... -> 2m上限,带容量上限淘汰),避免上游或签名服务异常时持续高频抓取与告警刷屏。ctx.Err() != nil/context.Canceled)不写入共享失败冷却;成功刷新、Invalidate与Clear时立即清除对应冷却状态。stale签名(标记为stale_cooldown)并将退避期日志降级为Debug(web_statsig_fetch_suppressed/web_statsig_using_stale_during_cooldown)。backend/internal/application/quotarecovery/service_test.gobackend/internal/infra/persistence/relational/repository_test.gobackend/internal/infra/provider/web/statsig_test.go验证结果
gofmt -l:全部修改文件无格式差异go vet ./...:通过go test -race -count=1 ./internal/application/quotarecovery ./internal/infra/persistence/relational ./internal/infra/provider/web ./internal/application/account ./internal/app:全部通过风险与注意事项
active状态后,下一次reconcileDue周期会自动将其到期窗口重新纳入恢复队列。(baseURL, signerURL, method, path)签名键,不影响其他路径;手动触发或防风控触发Invalidate时会立即清除退避窗口。