Repository navigation
Queue RevocationResponder work items to the global thread pool queue - #136022
Merged
rzikm merged 1 commit intoOct 19, 2026
Merged
Conversation
RevocationResponder runs its accept loop on a thread pool thread that blocks in HttpListener.GetContext for the lifetime of the listener. Previously, it queued each request handler with preferLocal: true. That puts the handler in the local queue of the blocked thread, where it can only run if another worker steals it, and workers only steal once the global queue is empty. When the test process keeps the global queue busy, the OCSP or CRL request is not answered before the platform's fetch timeout (3 seconds per fetch in trustd on macOS), and the chain reports RevocationStatusUnknown instead of Revoked. This is the likely cause of the failures in CertificateValidationRemoteServer.ConnectWithRevocation_WithCallback; queue saturation in CI has not been measured. Queue the accept loop and the request handlers with preferLocal: false. Fixes dotnet#134230
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov |
Contributor
|
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
Contributor
Author
|
Thank you for the review and the merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RevocationResponderis the loopback OCSP/CRL server used by the revocation tests. Under thread-pool load it can stop answering requests until the chain engine's fetch times out. When that happens,CertificateValidationRemoteServer.ConnectWithRevocation_WithCallback(checkRevocation: True)seesRevocationStatusUnknowninstead ofRevoked.Fixes #134230
Cause
The responder runs its accept loop as one thread-pool work item. Throughout the listener's lifetime, that work item waits for requests in
HttpListener.GetContext(). Each accepted request was queued withpreferLocal: true:On a pool thread,
preferLocal: truepushes the item into that thread's local queue. Here that thread goes straight back intoGetContext(), so the handler runs only if another worker steals it.ThreadPoolWorkQueue.Dequeuesteals only after the local, high-priority and global queues come up empty. So while the rest of the test process keeps the global queue busy, the OCSP and CRL requests sit unanswered. trustd gives up after its fixed 3-second per-fetch timer on macOS, and CryptoAPI after its per-URL timeout on Windows.This matches the failures linked from the issue's report. Of the report's 47 rows, 30 have links that still resolve: 25 are for
OSX.26.Arm64.Open, 3 are for Windows x86 checked, and 2 are for macOS 15 x64. In the six failing work items I downloaded:Collection: [RevocationStatusUnknown], and Windows reports[RevocationStatusUnknown, OfflineRevocation].Change
Queue the accept loop and the request handlers with
preferLocal: false, and add a comment explaining why. The change is test-only and applies to every test project that compilesRevocationResponder, including System.Net.Http, System.Net.Mail, System.Net.Quic, System.Net.Security and System.Security.Cryptography.Validation
I couldn't run the macOS or Windows legs locally. Instead I used a small console app on Linux x64 (32 cores) that compiles the real
CertificateAuthority.csandRevocationResponder.cs. It builds the same PKI as the test (OCSP for the end entity, CRLs everywhere, one intermediate, revoked leaf), then builds the chain withOnline,EndCertificateOnly,CustomRootTrustandUrlRetrievalTimeout = 3s. Meanwhile, CPU-bound work items keep re-queueing themselves to the global queue. The table shows the results at different loads:Before the change, each failing chain build in the local repro takes about 6 seconds, consistent with two 3-second fetch timeouts. Its leaf status is
[RevocationStatusUnknown, OfflineRevocation], the same as the Windows CI failure. In the recorded runs after the change, all three queueing sites usepreferLocal: false. Changing the accept-loop flag as well is a precaution against the same starvation when the thread that creates the responder then blocks synchronously.This shows the mechanism and that the change removes it. Whether CI processes reach this level of global-queue saturation is inferred from the timings above, not measured.
Note
This change was prepared with AI assistance (Anthropic Claude, checked by OpenAI Codex) at my request. I reviewed the change and the measurements before opening.