Skip to content

Fix DNS-over-QUIC stream lifetime under cancellation - #62

Open
zs311521 wants to merge 1 commit into
TechnitiumSoftware:developfrom
zs311521:fix/doq-stream-capacity-lifetime
Open

Fix DNS-over-QUIC stream lifetime under cancellation#62
zs311521 wants to merge 1 commit into
TechnitiumSoftware:developfrom
zs311521:fix/doq-stream-capacity-lifetime

Conversation

@zs311521

@zs311521 zs311521 commented Aug 9, 2026

Copy link
Copy Markdown

@ShreyasZare This fixes a deterministic DNS-over-QUIC stream-retention path reproduced while the peer's bidirectional-stream capacity is exhausted.

On current .NET 11 preview 6 with Microsoft MsQuic 2.5.9, cancelling OpenOutboundStreamAsync while it waits for peer capacity disposes an incompletely opened QuicStream. That requests native ABORT_SEND | ABORT_RECEIVE | IMMEDIATE (0xE); under sustained traffic, repeated timed-out queries leave native streams retained until the peer or connection catches up.

The change:

  • uses StreamCapacityCallback to maintain per-connection managed admission permits, so caller cancellation happens before a native stream is opened;
  • owns any admitted native open through terminal completion, preserves the original caller token and absolute query deadline, and observes late work;
  • serializes connection retirement and reports cleanup failures;
  • makes pooled connection leases and physical eviction explicit/single-flight so expired pooled connections are actually torn down;
  • keeps hot pool hits concurrent while cold construction remains single-owner.

Deterministic A/B verification against current develop:

  • stock: 202 native streams at peak with two intentionally held streams;
  • patched: peak stayed at the two held streams and returned to zero;
  • 1,000/1,000 caller cancellations preserved the original token;
  • native start/close/release/free traces balanced, with zero caller-driven 0xE;
  • 50 pool churn rounds across TCP/TLS/HTTPS/QUIC left no entry behind, and concurrent cleanup joined one result/failure;
  • five interleaved 60,000-query runs showed no throughput regression (36,645 stock vs 38,290 patched median QPS in the clean-branch run);
  • Release build on the exact preview-6 SDK: 0 warnings, 0 errors.

This is the concrete DoQ/native-lifetime mechanism observed in the forwarder-mode investigation related to TechnitiumSoftware/DnsServer#2030. It is deliberately not presented as an explanation for every report in that broader issue.

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