From 3993899af46505efaedc534fe954be3d6aa50e23 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Mon, 16 Dec 2024 12:03:52 +0530 Subject: [PATCH 1/3] fix: etcd watch restart when receive invalid revision --- apisix/core/config_etcd.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua index 5734106e7a7b..fc713df84043 100644 --- a/apisix/core/config_etcd.lua +++ b/apisix/core/config_etcd.lua @@ -257,6 +257,11 @@ local function do_run_watch(premature) end local rev = tonumber(res.result.header.revision) + if rev == nil then + log.warn("receive a invalid revision header, header: ", inspect(res.result.header)) + cancel_watch(http_cli) + break + end if rev > watch_ctx.rev then watch_ctx.rev = rev + 1 end @@ -284,7 +289,7 @@ local function run_watch(premature) local ok, err = ngx_thread_wait(run_watch_th, check_worker_th) if not ok then - log.error("check_worker thread terminates failed, retart checker, error: " .. err) + log.error("run_watch or check_worker thread terminates failed, retart those threads, error: " .. inspect(err)) end ngx_thread_kill(run_watch_th) From 54975a8dab72595d1985a33d66ea92961e2d95f8 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Mon, 16 Dec 2024 13:35:25 +0530 Subject: [PATCH 2/3] fix lint --- apisix/core/config_etcd.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua index fc713df84043..2ea06f6e2ebf 100644 --- a/apisix/core/config_etcd.lua +++ b/apisix/core/config_etcd.lua @@ -289,7 +289,8 @@ local function run_watch(premature) local ok, err = ngx_thread_wait(run_watch_th, check_worker_th) if not ok then - log.error("run_watch or check_worker thread terminates failed, retart those threads, error: " .. inspect(err)) + log.error("run_watch or check_worker thread terminates failed" + .. " restart those threads, error: ".. inspect(err)) end ngx_thread_kill(run_watch_th) From abeb5d027ab1a35e22e8990b3e5d4357cad33704 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 17 Dec 2024 13:45:45 +0530 Subject: [PATCH 3/3] indent fix --- apisix/core/config_etcd.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua index 2ea06f6e2ebf..a415fbfe527b 100644 --- a/apisix/core/config_etcd.lua +++ b/apisix/core/config_etcd.lua @@ -289,8 +289,8 @@ local function run_watch(premature) local ok, err = ngx_thread_wait(run_watch_th, check_worker_th) if not ok then - log.error("run_watch or check_worker thread terminates failed" - .. " restart those threads, error: ".. inspect(err)) + log.error("run_watch or check_worker thread terminates failed", + " restart those threads, error: ", inspect(err)) end ngx_thread_kill(run_watch_th)