Skip to content

Unify remaining sync/async pairs in the Always Encrypted command path #5113

Open

Description

@cheenamalhotra

Follow-up to #3672, after the five-layer split (#5077, #5079, #5080, #5081, #5085).

Internal sync/async pairs should share one implementation: no Async suffix, return
ValueTask, take bool isAsync and then the CancellationToken, and branch only at the I/O
call. Most of the key-store path follows this rule now. These pairs in the command path don't
yet:

  • Merge PrepareForTransparentEncryption and PrepareForTransparentEncryptionAsync
    (SqlCommand.Encryption.cs) into one ValueTask method. Remove the "null task means sync"
    signal in RunExecuteReaderTdsWithTransparentParameterEncryption (see its @TODO).
  • Align CompleteCachedQueryMetadataAsync and CompleteParameterEncryptionAsync with the
    same rule.
  • Merge EnclaveDelegate.CreateEnclaveSession and CreateEnclaveSessionAsync, so
    SqlCommand.CreateEnclaveSession passes isAsync through instead of branching.
  • Pick the cancellation token once at the entry point. Today callers repeat
    isAsync ? cancellationToken : CancellationToken.None.
  • Fix the two PrepareForTransparentEncryptionCore overloads. The summary
    ("bypassing the query metadata cache") is on the wrong overload.

Constraints: keep the worker hand-off before blocking TDS writes, re-check the connection after
every await, keep key loads sequential, and keep the bounded retry. No public API change.

Activity

  1. added this to the 8.1.0-preview1 milestone on Nov 18, 2026
  2. moved this from To triage to Backlog in SqlClient Boardon Nov 18, 2026
  3. github-actions commented on Nov 18, 2026

    @github-actions

    🔍 Triage Summary

    Check Result
    Issue type Task
    Environment Not applicable (internal refactoring task, not a bug report)
    Area Area\Async (also relevant: Always Encrypted command path)
    Duplicates None found; related parent/follow-up context: #3672, #5077, #5079, #5080, #5081, #5085
    Regression Not indicated

    Analysis

    This is an internal refactor following the five-layer split of the async-friendly Always Encrypted work (#3672). It unifies the remaining sync/async method pairs in the command path (SqlCommand.Encryption.cs, EnclaveDelegate) into single ValueTask implementations that take bool isAsync and branch only at the I/O call. There is no public API change. Severity is P3: the work is maintainability-focused, but it touches sensitive ordering and connection-state constraints.

    Next Steps

    • Assign this issue to Copilot coding agent or a maintainer to implement the checklist. Suggested starting points are PrepareForTransparentEncryption/Async, CompleteCachedQueryMetadataAsync, CompleteParameterEncryptionAsync, EnclaveDelegate.CreateEnclaveSession/Async, and the @TODO in RunExecuteReaderTdsWithTransparentParameterEncryption.
    • Preserve the stated constraints: worker hand-off before blocking TDS writes, connection re-check after every await, sequential key loads, and the bounded retry.
    • Add or update unit and manual tests covering both sync and async paths.

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for #5113 · copilot · auto · 16 AIC · ⌖ 11.3 AIC · ⊞ 7.8K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions