Skip to content

test: cover clearing of failed in-flight DNS requests so they can be retried - #3549

Open
pjfanning wants to merge 1 commit into
apache:mainfrom
pjfanning:dns-clear-inflight-on-failure
Open

pjfanning wants to merge 1 commit into
apache:mainfrom
pjfanning:dns-clear-inflight-on-failure

Conversation

@pjfanning

@pjfanning pjfanning commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Motivation

Port of the test from akka/akka-core#32114 (backport of akka/akka-core#32110), which covers AsyncDnsResolver clearing a failed resolution from its in-flight map so that a later resolve of the same name is retried rather than blocked.

Pekko's resolver already behaves this way - the ResolutionAnswer handler fans a failure out to every waiter and removes the in-flight entry - so no main-code change is needed, but this scenario had no regression test.

Modification

Add an AsyncDnsResolverSpec case: two senders resolve the same name, the second joins the in-flight resolution (no second question is sent), the DNS client replies with a failure, both senders receive Status.Failure, and a subsequent resolve from both senders is sent to the client again and succeeds.

The Akka test relies on a 1 ms resolve-timeout and an autopilot that ignores the first question. This port drives the client TestProbe explicitly instead (same style as the existing "reuse in-progress resolutions" case) so it has no timing dependency.

Result

The retry-after-failure behaviour of AsyncDnsResolver is covered by a test. No main-code change.

Tests

  • sbt "actor-tests/testOnly org.apache.pekko.io.dns.internal.AsyncDnsResolverSpec" - 22 passed, run 3 times
  • native scalafmt run on the changed file

References

None - port of the test from akka/akka-core#32114. Akka source is Apache-2.0 licensed as of 2023-09-20.

…retried

Motivation:
akka/akka-core#32114 fixed AsyncDnsResolver leaving failed resolutions in
its in-flight map, which blocked retries of the same name. Pekko's
resolver already clears the in-flight entry on failure, but there was no
regression test for it.

Modification:
Add an AsyncDnsResolverSpec case where two senders resolve the same name,
the DNS client fails, both senders receive the failure, and a subsequent
resolve from both senders is sent to the client again and succeeds.

Result:
The retry-after-failure behaviour of AsyncDnsResolver is covered by a test.

Tests:
- sbt "actor-tests/testOnly org.apache.pekko.io.dns.internal.AsyncDnsResolverSpec" (22 passed, run 3 times)
- native scalafmt run on the changed file

References:
None - port of the test from akka/akka-core#32114
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.

1 participant