SIGN IN SIGN UP
Kong / kong UNCLAIMED

🦍 The API and AI Gateway

0 0 1231 Lua

fix(router): route collision test causes failure when the initial router build comes with a large amount of routes (#10714)

This fixes a bug caused by the following reasons:

1. When new routes are inserted, an EE-specific feature called route-collision detection does some checks with 2 inputs:
  1. The newly inserted route;
  1. The latest router, by calling get_updated_router_immediate
1. get_updated_router_immediate tries to update the router. As it queries DB while rebuilding, it’s possible that changes happens during the rebuilding. In the event of too frequent route insertion, it may give up the current process of rebuilding, and let the next insertion trigger the rebuilding. When it gives up, the global variable ROUTE is left unchanged;
1. When a worker gets a whole lot of newly inserted routers, it may fail to build the first version of the router, and get_updated_router_immediate returns unchanged ROUTE, in this case, nil, to the is_route_crud_allowed_smart route-collision detection function;
1. is_route_crud_allowed_smart assumes that a router should always be present, it tries 2 methods to get the current router:
1. the return value of get_updated_router_immediate (passed by the API handler of /routes/:routes), which is nil here;
1. `runloop.get_router()`, which is a deprecated call that should be replaced with get_updated_router_immediate(), when called, it causes a 500

Fix KAG-5815
X
Xumin committed
f294e70e0cf017668eb99a478f9329a8517370ff
Parent: 318569a
Committed by GitHub <noreply@github.com> on 11/26/2024, 7:24:37 AM