bzp2010 commented on code in PR #12353:
URL: https://github.com/apache/apisix/pull/12353#discussion_r2159883179
##########
apisix/discovery/nacos/init.lua:
##########
@@ -371,40 +348,18 @@ function _M.nodes(service_name, discovery_args)
discovery_args.namespace_id or default_namespace_id
local group_name = discovery_args
and discovery_args.group_name or default_group_name
-
- local logged = false
- -- maximum waiting time: 5 seconds
- local waiting_time = 5
- local step = 0.1
- while not applications and waiting_time > 0 do
- if not logged then
- log.warn('wait init')
- logged = true
- end
- ngx.sleep(step)
- waiting_time = waiting_time - step
- end
-
- if not applications or not applications[namespace_id]
- or not applications[namespace_id][group_name]
- then
+ local key = get_key(namespace_id, group_name, service_name)
+ local value = nacos_dict:get(key)
Review Comment:
You're using `shdict:get` here to read a shared memory, and I'd like to
point out that it locks the shdict even when it reads the shared memory.
> ref:
https://github.com/openresty/lua-nginx-module/blob/master/src/ngx_http_lua_shdict.c#L1593-L1609
Each request will use this nodes function, which is obviously a very "hot"
function, which will limit the concurrency that can be handled by waiting for
locks, is this appropriate?
--
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]