]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: hlua: assume proxy_find_by_id() may return NULL on previously existing...
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 7 Oct 2026 10:43:35 +0000 (12:43 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 12 Oct 2026 07:38:11 +0000 (09:38 +0200)
Since 3.4 and dynamic backends, we may hit a race were a backend which
existed at the time the event was published does not exist anymore when
the event is processed. Previously it was assumed the proxy referenced
by a server event would always exist (since proxies couldn't be removed
dynamically), and a BUG_ON() ensured that. But it is not true anymore,
thus we need to check for proxy_find_by_id() NULL return value, which
indicates that the proxy was removed since, and thus it is not worth
looking for the server which triggered the event anyway.

It should be backported to 3.4.

src/hlua.c

index 255dccf0554bd0c41c159bc8d16f9856116c4c08..46d7cc96e62f6816a229a1cc60661b94739f8275 100644 (file)
@@ -9567,12 +9567,13 @@ __LJMP static void hlua_event_hdl_cb_push_args(struct hlua_event_sub *hlua_sub,
                 * (if it wasn't removed yet, SERVER_DEL will never succeed here)
                 */
                px = proxy_find_by_id(e_server->safe.proxy_uuid, PR_CAP_BE, 0);
-               BUG_ON(!px);
-               server = server_find_by_id_unique(px, e_server->safe.puid, e_server->safe.rid);
-               if (server) {
-                       lua_pushstring(hlua->T, "reference");
-                       hlua_fcn_new_server(hlua->T, server);
-                       lua_settable(hlua->T, -3);
+               if (px) {
+                       server = server_find_by_id_unique(px, e_server->safe.puid, e_server->safe.rid);
+                       if (server) {
+                               lua_pushstring(hlua->T, "reference");
+                               hlua_fcn_new_server(hlua->T, server);
+                               lua_settable(hlua->T, -3);
+                       }
                }
        }
 #if defined(HAVE_ACME)