Skip to content

fix: 亲和渠道失败后从最高优先级回退 (#152) - #162

Merged
woncc merged 1 commit into
mainfrom
cursor/upstream-issue-152-fcc241cdf-20261105
Nov 5, 2026
Merged

woncc merged 1 commit into
mainfrom
cursor/upstream-issue-152-fcc241cdf-20261105

Conversation

@woncc

@woncc woncc commented Nov 5, 2026

Copy link
Copy Markdown

🔗 关联任务 / Related Issue

Closes #152

上游:QuantumNous/new-api@fcc241c(QuantumNous#8078)

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)

📝 变更描述 / Description

原样 cherry-pick 上游修复。亲和渠道消耗一次请求尝试,但不消耗普通优先级层级;首次失败回退从最高优先级开始,跨组时清除偏移,保持原有重试预算和严格会话行为。只改三个授权文件,保留 fork 插件路由实现。

本 PR 由 Codex AI 辅助移植与验证,交由独立 reviewer 审核。已核对 git 身份 woncc 与近期核心提交历史一致。

📸 运行证明 / Proof of Work

基线生产代码搭配新增回归用例执行:GOMAXPROCS=2 RAYON_NUM_THREADS=2 GOWORK=off go test -p=2 ./controller/ -run '^TestChannelAffinityRetryPriorities$/^sqlite$/cache=false/^affinity_hit$' -count=1 -v,按预期失败:实际渠道序列 [27,27,30],预期 [27,24,27]。

修复候选执行:

GOMAXPROCS=2 RAYON_NUM_THREADS=2 GOWORK=off go test -p=2 ./controller/ ./service/ -run ^(TestChannelAffinityRetryPriorities|TestShouldRetryHonorsPinRetryMode|TestShouldRetryTaskRelayHonorsPinRetryMode|TestSameChannelPinsMergeToStricterRetryMode|TestShouldSkipRetryAfterChannelAffinityFailure|TestGetPreferredChannelByAffinity_RequestHeaderKeySource|TestClearCurrentChannelAffinityCache|TestCacheGetRandomSatisfiedChannelUsesTokenAutoGroupsWhenGlobalAutoIsEmpty)$ -count=1 -v

结果:controller、service 均 PASS;亲和优先级 54 场景全部通过,未跳过数据库。SQLite 3.50.4、MySQL 8.0.46、PostgreSQL 15.19;MySQL/PostgreSQL 使用测试夹具创建的独立数据库,测试后删除,仅复用现有本地引擎。连接参数经环境变量注入,不包含在正文中。

git diff --check HEAD^ HEAD 通过;三个文件 gofmt -l 无输出。未运行全量套件,未部署、合并或改动依赖。既有 DB 夹具初始化会输出 options 表尚未创建的日志,断言均通过;基线同样存在该日志。

✅ 提交前检查项 / Checklist

  • 人工确认: 待独立人工/审查流程确认
  • 非重复提交: fork 中检索完整上游标识,无已有 PR
  • 功能范围: 聚焦渠道亲和回退修复
  • 非透传: 不涉及透传行为
  • 范围聚焦: 仅授权三个文件
  • 本地验证: 实际命令与结果见上
  • 安全合规: 无凭据及无关变更

@woncc
woncc merged commit 62fd2a0 into main Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[上游/现在能解] fcc241cdf fix: start affinity fallback at the highest channel priority

2 participants