-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[PLATFORM-2274]: Investigate possible DNS caching issues on our rabbitmq libraries #199
[PLATFORM-2274]: Investigate possible DNS caching issues on our rabbitmq libraries #199
Conversation
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.
nice work! a few comments:
- does it work only for the first connection opening, or also for re-connections after errors?
- do you think it's possible to add a test that actually reproduces the issue where the first resolution fails but the second succeeds? you know, actually testing the
reduce_while
behavior - can you add a short description in the PR please please :c
Ehi @neslinesli93
|
if the library handles the reconnection itself (i don't remember tbh) then the process should be the same... otherwise yeah the clients should handle that |
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.
Nice 👍
Tests of actual resolution would be really cool, not sure if modifying the /etc/hosts
file or something like that could work 🤷
0fc438a
0fc438a
to
06ede36
Compare
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.
Mocking for the win
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.
❤️
@andreausu @cottinisimone i'm worried about
don't we risk to, in case of normal operations, connect always to the first node? |
It seems is not. The load balancer is balancing the ips during the resolution too. Here's the code i run to test it: 1..100
|> Enum.map(fn _ ->
'loud-azure-centipede.in.rmq4.cloudamqp.com'
|> Amqpx.DNS.resolve_ips()
|> Enum.map(&to_string/1)
|> Enum.join("-")
end)
|> Enum.group_by(fn v -> v end)
|> Enum.map(fn {k, v} -> {k, Enum.count(v)} end) |
I've always witnessed DNS servers returning answers for A records with multiple IPs associated in random order, but I'm not sure if that's by RFC or just a common implementation. |
https://prima-assicurazioni-spa.myjetbrains.com/youtrack/issue/PLATFORM-2274
This PR modifies the connection behavior of
amqpx
when connecting to a RabbitMQ cluster or host:host
field in the connection parameters or the RabbitMQ URL is an IP address, the library will establish a direct connection to that IP.host
field in the connection parameters or the RabbitMQ URL is a DNS record, the library will resolve the associatedA
records and attempt to connect to the first available IP address.