You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/07/29 17:46:51 UTC

[GitHub] [incubator-apisix] nic-chen commented on a change in pull request #1888: change: add more prometheus metrics(etcd modify index)

nic-chen commented on a change in pull request #1888:
URL: https://github.com/apache/incubator-apisix/pull/1888#discussion_r462343820



##########
File path: apisix/core/config_etcd.lua
##########
@@ -221,10 +221,22 @@ local function sync_data(self)
         return true
     end
 
-    local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1)
+    local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1, self.timeout)
+
     log.info("waitdir key: ", self.key, " prev_index: ", self.prev_index + 1)
     log.info("res: ", json.delay_encode(dir_res, true))
     if not dir_res then
+        -- for fetch the last etcd index
+        local key_res, _ = getkey(self.etcd_cli, self.key)
+        if key_res and key_res.headers then
+            local key_index = key_res.headers["X-Etcd-Index"]
+            local key_idx = key_index and tonumber(key_index) or 0
+            if key_idx and key_idx > self.prev_index then
+                -- Avoid the index to exceed 1000 by updating other keys that will causing a full reload

Review comment:
       I have split that into two lines.




----------------------------------------------------------------
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:
users@infra.apache.org