Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: etcd compact err【do not merge me! only for discussion】 #11149

Closed
Closed
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions apisix/core/config_etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
--- Get configuration information.
--
-- @module core.config_etcd

local table = require("apisix.core.table")
local config_local = require("apisix.core.config_local")
local log = require("apisix.core.log")
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about the change?

Suggested change
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
log.info("updating prev_index from "..self.prev_index.." to "..rev )
self:upgrade_version(rev)

end
if err == "compacted" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't remove these codes, we should keep them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

self.need_reload = true
log.warn("waitdir [", self.key, "] err: ", err,
", will read the configuration again via readdir")
return false
goto fail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to change the workflow

end

::fail::
return false, err
end

log.info("waitdir success")
local res = dir_res.body.node
local err_msg = dir_res.body.message
if err_msg then
Expand Down
Loading