Open
Conversation
Owner
|
@xvhuan 冲突需要处理一下。 |
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.
背景
线上排查里,
accounts.extra的更新仍然会把很多“只用于展示/观测”的字段也升级成scheduler_outbox.account_changed,从而带出一整条额外链路:scheduler_outbox这在
codex_*快照和session_window_utilization这种高频观测字段上放大得尤其明显。这次 PR 的目标不是泛化优化,而是先把已经确认不影响调度分桶的那一小组
extra字段单独收紧,避免继续放大 outbox 和 bucket rebuild。改动内容
1.
UpdateExtra改为按 key 分类在 repository 层给
UpdateExtra(...)增加键级别判断:account_changed:codex_primary_*codex_secondary_*codex_5h_*codex_7d_*codex_usage_updated_atsession_window_utilizationaccount_changed也就是说,这次是保守白名单,不是黑名单放行。
2. 观测字段仍尽量补单账号缓存
对于被判定为 scheduler-neutral 的
extra更新:scheduler_outboxExtra这样可以避免 bucket rebuild,同时尽量不让
GetAccount(...)命中的缓存落后太多。为什么这样做
mixed_scheduling、model_rate_limits这类真正影响调度或账号选择的字段,这次完全不碰。风险控制
scheduler_outbox消费逻辑。测试
静态与 unit
docker run --rm -v /home/ius/sub2api/backend:/src -w /src golangci/golangci-lint:v2.9.0 golangci-lint run --timeout=30mdocker run --rm -v /home/ius/sub2api/backend:/src -w /src golang:1.26.1 /usr/local/go/bin/go test -tags=unit ./...repository integration
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /home/ius/sub2api/backend:/src -w /src golang:1.26.1 /usr/local/go/bin/go test -tags=integration ./internal/repository -count=1新增覆盖:
UpdateExtra更新codex_* / session_window_utilization时不写 outboxmixed_scheduling这类调度相关键仍然会写 outbox本地 Docker 回归
docker compose -f /tmp/sub2api-prtest-compose.yml up -d --buildGET /health返回200GET /api/v1/settings/public返回200POST /api/v1/auth/login返回200GET /api/v1/admin/dashboard/snapshot-v2返回200GET /api/v1/admin/dashboard/users-trend返回200本地小并发
settings/public并发 30 请求:全部200snapshot-v2并发 20 请求:全部200fork CI
CI:通过Security Scan:通过