[PR #1699] [MERGED] Use tokio JoinSet for internally spawned server/resolver tasks #2530

Closed
opened 2026-03-16 10:06:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/1699
Author: @jeff-hiner
Created: 4/19/2022
Status: Merged
Merged: 9/13/2022
Merged by: @bluejekyll

Base: mainHead: taskset


📝 Commits (5)

  • 6c01147 Require tokio 1.21
  • e43cae6 Use JoinSet for server tokio tasks
  • c70d7d8 Use JoinSet for resolver tokio tasks
  • 66774d9 Late fixups
  • d611280 Avoid verbose types via imports

📊 Changes

19 files changed (+95 additions, -100 deletions)

View changed files

📝 Cargo.lock (+2 -2)
📝 bin/Cargo.toml (+1 -1)
📝 crates/recursor/src/recursor.rs (+6 -3)
📝 crates/resolver/Cargo.toml (+1 -1)
📝 crates/resolver/examples/flush_cache.rs (+1 -1)
📝 crates/resolver/examples/global_resolver.rs (+1 -1)
📝 crates/resolver/examples/multithreaded_runtime.rs (+1 -1)
📝 crates/resolver/src/async_resolver.rs (+23 -23)
📝 crates/resolver/src/dns_sd.rs (+1 -1)
📝 crates/resolver/src/https.rs (+1 -1)
📝 crates/resolver/src/name_server/connection_provider.rs (+8 -3)
📝 crates/resolver/src/name_server/name_server.rs (+2 -2)
📝 crates/resolver/src/name_server/name_server_pool.rs (+6 -3)
📝 crates/resolver/src/resolver.rs (+2 -2)
📝 crates/resolver/src/tls/mod.rs (+1 -1)
📝 crates/server/Cargo.toml (+2 -2)
📝 crates/server/src/server/server_future.rs (+33 -50)
📝 crates/server/src/store/forwarder/authority.rs (+1 -1)
📝 crates/server/tests/forwarder.rs (+2 -1)

📄 Description

Switching to JoinSet has a few nice advantages.

The first and most obvious advantage is less code to maintain. No custom drop impl, no more newtype wrapper around JoinHandle.

The next is easier cancel safety-- from a resolver perspective, each connection has its own set of tasks corresponding to pending queries. If a server terminates and drops a JoinSet containing multiple pending queries, every waiting task will abort when it hits an await point (generally this means immediately). In practice this means cleanup is more predictable, open sockets are dropped more quickly, and there's less noise in logs. Tasks abort rather than continuing despite nowhere to send results and emitting late log messages about broken channels.

Finally, this makes it a little more feasible to shift to a model where a server can autonomously restart failed sockets-- again, any in-flight transactions that can't be completed are automatically aborted when the parent JoinSet is dropped, so it's easier to reason that old responses won't be sent over a new connection.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/1699 **Author:** [@jeff-hiner](https://github.com/jeff-hiner) **Created:** 4/19/2022 **Status:** ✅ Merged **Merged:** 9/13/2022 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `main` ← **Head:** `taskset` --- ### 📝 Commits (5) - [`6c01147`](https://github.com/hickory-dns/hickory-dns/commit/6c0114749761a87d96105dffdc9d9f98e86f69bd) Require tokio 1.21 - [`e43cae6`](https://github.com/hickory-dns/hickory-dns/commit/e43cae6e2c5f2de9f84e555dd6d8218fcd12914b) Use JoinSet for server tokio tasks - [`c70d7d8`](https://github.com/hickory-dns/hickory-dns/commit/c70d7d8d8bd03d215a5ec821f49f07871207cd80) Use JoinSet for resolver tokio tasks - [`66774d9`](https://github.com/hickory-dns/hickory-dns/commit/66774d9d3e7ee2e413034ae4919d8211a85bfb9d) Late fixups - [`d611280`](https://github.com/hickory-dns/hickory-dns/commit/d611280e6aa6b207b2698ce90bc673ba6e260d95) Avoid verbose types via imports ### 📊 Changes **19 files changed** (+95 additions, -100 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+2 -2) 📝 `bin/Cargo.toml` (+1 -1) 📝 `crates/recursor/src/recursor.rs` (+6 -3) 📝 `crates/resolver/Cargo.toml` (+1 -1) 📝 `crates/resolver/examples/flush_cache.rs` (+1 -1) 📝 `crates/resolver/examples/global_resolver.rs` (+1 -1) 📝 `crates/resolver/examples/multithreaded_runtime.rs` (+1 -1) 📝 `crates/resolver/src/async_resolver.rs` (+23 -23) 📝 `crates/resolver/src/dns_sd.rs` (+1 -1) 📝 `crates/resolver/src/https.rs` (+1 -1) 📝 `crates/resolver/src/name_server/connection_provider.rs` (+8 -3) 📝 `crates/resolver/src/name_server/name_server.rs` (+2 -2) 📝 `crates/resolver/src/name_server/name_server_pool.rs` (+6 -3) 📝 `crates/resolver/src/resolver.rs` (+2 -2) 📝 `crates/resolver/src/tls/mod.rs` (+1 -1) 📝 `crates/server/Cargo.toml` (+2 -2) 📝 `crates/server/src/server/server_future.rs` (+33 -50) 📝 `crates/server/src/store/forwarder/authority.rs` (+1 -1) 📝 `crates/server/tests/forwarder.rs` (+2 -1) </details> ### 📄 Description Switching to JoinSet has a few nice advantages. The first and most obvious advantage is less code to maintain. No custom drop impl, no more newtype wrapper around JoinHandle. The next is easier cancel safety-- from a resolver perspective, each connection has its own set of tasks corresponding to pending queries. If a server terminates and drops a JoinSet containing multiple pending queries, every waiting task will abort when it hits an await point (generally this means immediately). In practice this means cleanup is more predictable, open sockets are dropped more quickly, and there's less noise in logs. Tasks abort rather than continuing despite nowhere to send results and emitting late log messages about broken channels. Finally, this makes it a little more feasible to shift to a model where a server can autonomously restart failed sockets-- again, any in-flight transactions that can't be completed are automatically aborted when the parent JoinSet is dropped, so it's easier to reason that old responses won't be sent over a new connection. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 10:06:28 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#2530
No description provided.