nic-chen commented on code in PR #11149:
URL: https://github.com/apache/apisix/pull/11149#discussion_r1562177939
##########
apisix/core/config_etcd.lua:
##########
@@ -328,21 +327,43 @@ local function sync_data(self)
return true
end
+ ::waitdir::
+ -- get latest uncompacted revision
+ local res, err = self.etcd_cli:get('/nonexisting',{
+ count_only = true,
+ range_end = "\0"
+ })
+ if err then
+ log.error("failed to get latest uncompacted revision: ", err)
+ end
+ local rev
+ if res and res.body and res.body.header and res.body.header.revision then
+ rev = tonumber(res.body.header.revision)
+ end
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
+ if err == "timeout" then
+ log.info("updating prev_index from "..self.prev_index.." to "..rev
)
+ if rev then
+ if rev == self.prev_index then
+ goto fail
+ end
+ self.prev_index = rev
+ end
+ goto waitdir
+ end
if err == "compacted" then
self.need_reload = true
log.warn("waitdir [", self.key, "] err: ", err,
", will read the configuration again via readdir")
- return false
+ goto fail
Review Comment:
we don't need to change the workflow
--
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]