Similarityoung commented on code in PR #966:
URL: https://github.com/apache/dubbo-go-pixiu/pull/966#discussion_r3611674016


##########
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:
   请让生产写入在持有 s.mu 后生成 lastFailure,再按同一顺序 PushBack,避免链表顺序与用于 TTL 的时间戳顺序分离。 
markEndpointCooldown 当前先计算 time.Now() 
再进入这里的互斥锁,并发请求可能让较新的失败先写入、较旧的失败后写入;容量满时下一次插入会淘汰链表头的较新失败,使仍处于 60 秒 cooldown 的 
endpoint 立即恢复可选。



-- 
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]

Reply via email to