[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-5121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139884#comment-18139884
 ] 

Andrew Kyle Purtell commented on ZOOKEEPER-5121:
------------------------------------------------

[~andor] A better fix here in my opinion would be to align to the DNS related 
behaviors of the C client and Java client. The change history of the C client 
indicates the C client's periodic DNS re-resolution was introduced on 
ZOOKEEPER-1355 and refined with ZOOKEEPER-1998, developing some semantics and 
capabilities that diverge from the Java client that seem good to keep. Aligning 
the Java and C clients' DNS lookup related behaviors could be future work.

Let me write it here for future reference: The quorum connect string would be 
the source of truth. For each entry in the list the client would also store the 
last-known good set of resolved addresses. The client resolves as needed for 
connect() attempts. The DNS resolution is performed with an async/wait approach 
so ping, receive, and session timeout processing are independently of any 
blocking behavior in the DNS resolver.  If a name does not resolve, the client 
continues to try that entry's last-known good address. Otherwise it will skip 
the entry for the current connect() attempt. If every entry in the list fails 
to connect(), the client will back off and try again. The session timeout 
determines when the connect() attempts stop, at session expiration time. If a 
name resolves to several addresses, the client may try any or all of them. This 
is C client behavior that the Java client would adopt. Clients pick up DNS 
changes on the any connect(). Applications that need faster detection could 
enable an optional background refresh with some minimum refresh interval. A 
failed refresh would change no state. Both the C client and the Java would 
behave identically during DNS outages, partial failures and topology changes.

> (C client) DNS lookup failures can disrupt the client
> -----------------------------------------------------
>
>                 Key: ZOOKEEPER-5121
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5121
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: c client
>            Reporter: Andrew Kyle Purtell
>            Assignee: Andrew Kyle Purtell
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {panel}
> The C client resolves server addresses synchronously inside its main I/O 
> loop. When a DNS lookup fails, the loop exits without sending heartbeats or 
> attempting to reconnect. It also leaves output parameters uninitialized, 
> feeding invalid state into {{{}poll(){}}}. Brief DNS blips can silently 
> expire healthy sessions and prevent disconnected clients from falling back to 
> known addresses.
> The proposed fix decouples address re-resolution into a rate-limited periodic 
> refresh. If a lookup fails, the client retains and uses its cached server 
> addresses, reserving hard resolver errors strictly for initial setup calls 
> ({{{}zookeeper_init{}}} and {{{}zoo_set_servers{}}}).
> The event loop now guarantees safe fallback outputs on any early return, 
> preventing poll corruption.
> A new test verifies that heartbeats, timeouts, and reconnection attempts 
> continue uninterrupted throughout simulated DNS outages.
> {panel}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to