Skip to content
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

Dynamic Server List #594

Merged
merged 35 commits into from Nov 3, 2023
Merged

Dynamic Server List #594

merged 35 commits into from Nov 3, 2023

Conversation

bradh352
Copy link
Member

@bradh352 bradh352 commented Nov 2, 2023

This PR makes the server list a dynamic sorted list of servers. The sort order is [ consecutive failures, system config index ]. The server list can be updated via ares_set_servers_*(). Any queries currently directed to servers that are no longer in the list will be automatically re-queued to a different server.

Also, any time a failure occurs on the server, the sort order of the servers will be updated so that the one with the fewest consecutive failures is chosen for the next query that goes on the wire, this way bad or non-responsive servers are automatically isolated.

Since the server list is now dynamic, the tracking of query failures per server has been removed and instead is relying on the server sort order as previously described. This simplifies the logic while also reducing the amount of memory required per query. However, because of this dynamic nature, it may not be easy to determine the server attempt order for enqueued queries if there have been any failures.

If using the ARES_OPT_ROTATE, this is now implemented to be a random selection of the configured servers. Since the server list is dynamic, its not possible to go to the next server as configuration could have changed between queries or attempts for the same query.

Finally, this PR moved some existing functions into new files to logically separate them.

This should address issues #550 and #440, while also setting the framework to implement #301. #301 needs a little more effort since it configures things other than the servers themselves (domains, search, sortlist, lookups), which need to make sure they can be safely updated.

Fix By: Brad House (@bradh352)

@bradh352
Copy link
Member Author

bradh352 commented Nov 3, 2023

alright, after that last commit, think things should build fully

@bradh352 bradh352 requested a review from bagder November 3, 2023 01:45
@bradh352 bradh352 merged commit c8bd83a into c-ares:main Nov 3, 2023
24 checks passed
@bradh352 bradh352 deleted the sorted_servers branch November 4, 2023 01:33
vojtechvobr added a commit to vojtechvobr/c-ares that referenced this pull request Feb 15, 2024
ares__strsplit provides a newly allocated buffer, so suffix list in
line variable isn't referenced anymore. Related ares_free seems to
have gone missing during refactoring made in c-ares#594
bradh352 pushed a commit that referenced this pull request Feb 15, 2024
ares__strsplit provides a newly allocated buffer, so suffix list in
line variable isn't referenced anymore. Related ares_free seems to
have gone missing during refactoring made in #594

Fix By: Vojtěch Vobr (@vojtechvobr)
bradh352 pushed a commit that referenced this pull request Feb 15, 2024
ares__strsplit provides a newly allocated buffer, so suffix list in
line variable isn't referenced anymore. Related ares_free seems to
have gone missing during refactoring made in #594

Fix By: Vojtěch Vobr (@vojtechvobr)
bradh352 pushed a commit that referenced this pull request Feb 15, 2024
ares__strsplit provides a newly allocated buffer, so suffix list in
line variable isn't referenced anymore. Related ares_free seems to
have gone missing during refactoring made in #594

Fix By: Vojtěch Vobr (@vojtechvobr)
bradh352 pushed a commit that referenced this pull request Feb 15, 2024
ares__strsplit provides a newly allocated buffer, so suffix list in
line variable isn't referenced anymore. Related ares_free seems to
have gone missing during refactoring made in #594

Fix By: Vojtěch Vobr (@vojtechvobr)
bradh352 pushed a commit that referenced this pull request Feb 15, 2024
ares__strsplit provides a newly allocated buffer, so suffix list in
line variable isn't referenced anymore. Related ares_free seems to
have gone missing during refactoring made in #594

Fix By: Vojtěch Vobr (@vojtechvobr)
@nUl1 nUl1 mentioned this pull request Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant