Repository navigation
Conversation
…#103) Hidden models (user-unchecked on the 模型 page) stay servable when requested explicitly but are now excluded from: - ProbeRound (no more real upstream requests for hidden models) - nextCandidate (hidden models won't become failover substitutes) - Candidates() hint list Lane.SetHidden() holds an independent hidden set, seeded from cfg.HiddenModels at boot and hot-applied on visibility changes.
…Gcomcom#103) probeTargets took the read lock while ProbeRound still held the write lock; sync.RWMutex is not reentrant, so the round deadlocked and every caller that waited for a verdict hung with it. The filtered copy is now built by probeTargetsLocked, and probeTargets is only for callers that do not already hold the lock. Tests: hidden models stay out of both the probe round and the candidate list, come back when unhidden, and a round with every model hidden still returns.
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.
问题
模型页取消勾选的模型(
cfg.HiddenModels),只是从选择器和GET /v1/models里消失。lane依然每轮探测它们,限流切换时也依然把它们当替补。结果是:一个用户明确关掉的模型,持续收到真实上游请求、持续消耗免费额度。在按额度计的免费车道上,这不只是浪费,还是把用户主动省下的配额替用户花掉。
修复
Lane新增hidden map[string]bool与SetHidden([]string)ProbeRound取目标时改用过滤后的目录,隐藏模型不进入本轮探测;全部隐藏时本轮直接空转nextCandidate跳过隐藏 id,Candidates()随之干净cfg.HiddenModels播种,可见性接口里热应用(不必重启)Complete仍走BaseModelId(req.Model)。隐藏的语义是"不自动用它",不是"禁用"一个必须说清的坑
第一版过滤函数是自锁的:它在
ProbeRound持有写锁期间去拿读锁,而sync.RWMutex不可重入 —— 于是整轮探测死锁,所有等结论的调用方一起挂住。这里的实测表现很能说明问题:TestReprobeCoversCustomProviderModels从 5s 变成 2 分 09 秒直至超时。现在拆成
probeTargetsLocked()(供已持锁者调用)与probeTargets()(自己拿读锁)两个,ProbeRound走前者。测试
internal/lane/hidden_test.go钉死三件事:ProbeRound仍会返回 —— 用 goroutine + 10s 超时兜住死锁回归。go build ./.../go vet ./...通过;go test ./...全绿(internal/gateway28.3s、internal/lane34.9s)。Closes #103