-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dns): function to force no sync toip() #12739
Conversation
28ea225
to
27c5b5e
Compare
hi @locao as I’m trying to implement a new DNS client library based on mlcache (see PR #12305), and in that implmentation, the DNS query operation was implemented in the mlcache L3 callback. It deprecates the So I have one concern that if we update kong to the new DNS library, we might not support If the wasm module must rely on a singleton DNS library, I need to reconsider how to handle it in the new DNS library. (I currently haven't come up with a good method to implement individual queries on top of mlcache, as this would completely disrupt mlcache's optimal usage pattern and make the code more complex. 😿 ) |
f4fa6f0
to
9cd917c
Compare
Hi @chobits. If the new DNS client library behaves exactly the same way for the wasm module as for the lua land, there's nothing to worry about. As the current DNS client is not being removed at the moment, I think we should move forward with this change. Maybe we can change the What do you think? |
9cd917c
to
9dbe37f
Compare
Yes, it behaves the same way for all the upper callers. I have take a thorough look at the KAG issue, and know that your concern is the race-condition of current DNS client library. But in new DNS client library we still have that race-condition caused by the internal use of resty-lock by mlcache. Could that work for wasm? BTW, I know in that KAG issue, there is a semaphore lock race condition in the scenario of wasm using the DNS library. Could you explain why wasm could not tolerant the race condition if there is no dead-lock problem and semaphore lock seems not to cause CPU blocking. And I think it could help kong alleviate the pressure of queries on the DNS server.
It does not matter for the function name. I can provide a same function for wasm to be compatible with current DNS library.
|
9dbe37f
to
0e5d244
Compare
The old DNS library is problematic for the ngx_wasm_module Lua bridge because of its use of the semaphore Lua library, which the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I discussed with @locao offline, the WASM module could be responsible for compatibility with both new and old libraries, like
-- In the wasm module:
local toip = dns_client.toip
-- For original dns client library, it will use its `individual_toip` function.
if dns_client.individual_toip then
topip = dns_client.individual_toip
end
0e5d244
to
5eeaea2
Compare
Successfully created cherry-pick PR for |
(cherry picked from commit 48cd3a0)
Summary
This change adds new
individual_toip()
public function to the DNS client.This function bypasses the
noSynchronisation = false
option, forcing individual resolve of the hostnames. It avoids race-conditions when multiple calls to theaccess()
phase handler happen in the context of the same request.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
KAG-3795