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



##########
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:
       this line is too long

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

Review comment:
       that is wrong. we need to fetch the last etcd index before `local 
dir_res, err = waitdir(... ...`




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