hnlq715 commented on a change in pull request #3300:
URL: https://github.com/apache/apisix/pull/3300#discussion_r566543075



##########
File path: apisix/balancer/ewma.lua
##########
@@ -35,73 +58,69 @@ local function decay_ewma(ewma, last_touched_at, rtt, now)
     return ewma
 end
 
-
 local function store_stats(upstream, ewma, now)
     local success, err, forcible = shm_last_touched_at:set(upstream, now)
     if not success then
-        core.log.error("balancer_ewma_last_touched_at:set failed ", err)
+        core.log.error("shm_last_touched_at:set failed: ", err)
     end
     if forcible then
-        core.log.warn("balancer_ewma_last_touched_at:set valid items forcibly 
overwritten")
+        core.log.warn("shm_last_touched_at:set valid items forcibly 
overwritten")
     end
 
     success, err, forcible = shm_ewma:set(upstream, ewma)
     if not success then
-        core.log.error("balancer_ewma:set failed ", err)
+        core.log.error("shm_ewma:set failed: ", err)
     end
     if forcible then
-        core.log.warn("balancer_ewma:set valid items forcibly overwritten")
+        core.log.warn("shm_ewma:set valid items forcibly overwritten")
     end
 end
 
-
 local function get_or_update_ewma(upstream, rtt, update)
+    local lock_err = nil
+    if update then
+        lock_err = lock(upstream)
+    end
+
     local ewma = shm_ewma:get(upstream) or 0
+    if lock_err ~= nil then

Review comment:
       ~~We need to return ewma value for get and failed update operation.~~
   
   Reconsider this, I think it's ok to move this block, for now we do not use 
this ewma in update operation.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to