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

yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 142596d58433796ec2ae75f726c909919402d42e
Author: Jianghua Yang <[email protected]>
AuthorDate: Mon Dec 30 18:16:36 2024 +0800

    fix ic-proxy mis-disconnect addrs after reload config file (#14415)
    
        After we reload the config using pg_reload_conf,  ic-proxy progress 
will call
        ic_proxy_server_on_signal to process, It will compare the new addrs 
with the
        old addrs, both the old and new lists must be sorted by dbid, the 
caller is responsible
        to ensure this. If the addr is removed, it will be disconnected, if 
some addrs are added,
        we will establish the connection, however, old addrs maybe not sorted 
by dbid in guc
        gp_interconnect_proxy_addresses, although it is sorted, the function 
uv_getaddrinfo
        is asynchronous and can not guarantee the addrs parsed from 
gp_interconnect_proxy_addresses
        are added sequentially to ic_proxy_addrs.
        So some addr may be mis-disconnected and lead to select gp_segment_id, 
pg_reload_conf() from gp_dist_random('gp_id') failed, Error interconnect error: 
connection closed prematurely
    
        Before reloading the config file. we should sort ic_proxy_addrs by dbid 
to avoid
        mis-disconnecting of addrs.
---
 contrib/interconnect/proxy/ic_proxy_addr.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/contrib/interconnect/proxy/ic_proxy_addr.c 
b/contrib/interconnect/proxy/ic_proxy_addr.c
index edc5dd4cfa..b47f533936 100644
--- a/contrib/interconnect/proxy/ic_proxy_addr.c
+++ b/contrib/interconnect/proxy/ic_proxy_addr.c
@@ -234,6 +234,11 @@ ic_proxy_reload_addresses(uv_loop_t *loop)
         * of the addresses.
         */
        ic_proxy_prev_addrs = ic_proxy_list_free_deep(ic_proxy_prev_addrs);
+       /*
+        * before reloading the config file. we should sort ic_proxy_addrs by 
dbid to
+        * avoid mis-disconnecting of addrs.
+       */
+       list_sort(ic_proxy_addrs, ic_proxy_addr_compare_dbid);
        ic_proxy_prev_addrs = ic_proxy_addrs;
        ic_proxy_addrs = NULL;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to