This is an automated email from the ASF dual-hosted git repository.

nic443 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ddfc9260 fix: race condition problem while update upstream.nodes 
(#11916)
2ddfc9260 is described below

commit 2ddfc9260dca69529206b1193de0b88f411aaa88
Author: Nic <[email protected]>
AuthorDate: Fri Feb 7 14:41:44 2025 +0800

    fix: race condition problem while update upstream.nodes (#11916)
    
    Signed-off-by: Nic <[email protected]>
---
 apisix/upstream.lua | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/apisix/upstream.lua b/apisix/upstream.lua
index 3853623e5..e33f70533 100644
--- a/apisix/upstream.lua
+++ b/apisix/upstream.lua
@@ -300,10 +300,10 @@ function _M.set_by_route(route, api_ctx)
                 return HTTP_CODE_UPSTREAM_UNAVAILABLE, "invalid nodes format: 
" .. err
             end
 
-            up_conf.nodes = new_nodes
-            up_conf.original_nodes = up_conf.nodes
-
             local new_up_conf = core.table.clone(up_conf)
+            new_up_conf.nodes = new_nodes
+            new_up_conf.original_nodes = up_conf.nodes
+
             core.log.info("discover new upstream from ", up_conf.service_name, 
", type ",
                           up_conf.discovery_type, ": ",
                           core.json.delay_encode(new_up_conf, true))

Reply via email to