Re: [PR] fix: resync etcd when a lower revision is found [apisix]

2025-03-05 Thread via GitHub


guoqqqi merged PR #12015:
URL: https://github.com/apache/apisix/pull/12015


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



Re: [PR] fix: resync etcd when a lower revision is found [apisix]

2025-03-04 Thread via GitHub


Revolyssup commented on code in PR #12015:
URL: https://github.com/apache/apisix/pull/12015#discussion_r1980752912


##
apisix/core/config_etcd.lua:
##
@@ -262,9 +262,15 @@ local function do_run_watch(premature)
 cancel_watch(http_cli)
 break
 end
-if rev > watch_ctx.rev then
-watch_ctx.rev = rev + 1
+
+if rev < watch_ctx.rev then
+log.error("received smaller revision, rev=", rev, ", 
watch_ctx.rev=",
+  watch_ctx.rev,". etcd may be restarted. resyncing")
+produce_res(nil, "restarted")
+cancel_watch(http_cli)
+break
 end
+watch_ctx.rev = rev + 1

Review Comment:
   updated the code.
   1. Smaller revision -> Cause resync
   2. Equal revision -> Do nothing like previous
   3. Bigger revision -> Increment watch_ctx.rev



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



Re: [PR] fix: resync etcd when a lower revision is found [apisix]

2025-03-04 Thread via GitHub


nic-chen commented on code in PR #12015:
URL: https://github.com/apache/apisix/pull/12015#discussion_r1980511205


##
apisix/core/config_etcd.lua:
##
@@ -262,9 +262,15 @@ local function do_run_watch(premature)
 cancel_watch(http_cli)
 break
 end
-if rev > watch_ctx.rev then
-watch_ctx.rev = rev + 1
+
+if rev < watch_ctx.rev then
+log.error("received smaller revision, rev=", rev, ", 
watch_ctx.rev=",
+  watch_ctx.rev,". etcd may be restarted. resyncing")
+produce_res(nil, "restarted")
+cancel_watch(http_cli)
+break
 end
+watch_ctx.rev = rev + 1

Review Comment:
   what will happen when `rev == watch_ctx.rev` ?



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



Re: [PR] fix: resync etcd when a lower revision is found [apisix]

2025-03-03 Thread via GitHub


membphis commented on code in PR #12015:
URL: https://github.com/apache/apisix/pull/12015#discussion_r1977276165


##
apisix/core/config_etcd.lua:
##
@@ -262,9 +262,13 @@ local function do_run_watch(premature)
 cancel_watch(http_cli)
 break
 end
-if rev > watch_ctx.rev then
-watch_ctx.rev = rev + 1
+if rev < watch_ctx.rev then
+log.warn("received smaller revision, rev=", rev, ", 
watch_ctx.rev=", watch_ctx.rev,". etcd may be restarted. resyncing")

Review Comment:
   we should use a error log level



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