AlexStocks commented on code in PR #966:
URL: https://github.com/apache/dubbo-go-pixiu/pull/966#discussion_r3749644489
##########
pkg/filter/llm/proxy/filter.go:
##########
@@ -500,13 +510,20 @@ func (s *cooldownStore) markFailure(clusterName string,
endpoint *model.Endpoint
defer s.mu.Unlock()
key := newCooldownKey(clusterName, endpoint)
s.sweepExpiredIfNeededLocked(time.Now(), key)
- if _, ok := s.lastFailureByEndpoint[key]; !ok {
- s.evictOldestIfFullLocked(key)
+ ttl := endpointCooldownInterval(endpoint)
+ if element, ok := s.lastFailureByEndpoint[key]; ok {
+ entry := element.Value.(*cooldownEntry)
+ entry.lastFailure = lastFailure
+ entry.ttl = ttl
+ s.recencyOrder.MoveToBack(element)
+ return
}
- s.lastFailureByEndpoint[key] = cooldownEntry{
+ s.evictOldestIfFullLocked()
+ s.lastFailureByEndpoint[key] = s.recencyOrder.PushBack(&cooldownEntry{
Review Comment:
[P1] 请补一条能守住锁内取时的并发回归测试
当前实现已经把 `nowFn()` 放进 `s.mu`
临界区,生产修复本身成立;但现有测试没有制造“旧时间先采样、却晚于新时间插入链表”的交错。我在当前 exact Head 的隔离副本把
`lastFailure := s.nowFn()` 移回 `s.mu.Lock()` 前,`go test -count=10 -race
./pkg/filter/llm/proxy` 仍然全绿。随后加入一个确定性探针:阻塞第一次 `nowFn`,让第二次失败先完成,再填满容量触发淘汰;Head
连续 20 次通过,而该变异稳定保留旧记录并删除新记录。请把这个交错补进正式测试,断言容量溢出时旧 timestamp 被淘汰、新 timestamp 仍在
cooldown,避免本次并发修复以后无声回退。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]