You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simplify async enclave execution state and retry handling #5114
The async enclave execution path works, but its state handling is spread out and hard to
follow. Simplify it without changing behavior:
Give _enclaveAttestationInProgress one owner. It is set or cleared in four places today: CompleteParameterEncryptionAsync, PrepareForTransparentEncryption
(inProgressFlagWasSet), PrepareForTransparentEncryptionAsync
(ownsInProgressFlag/handedOff), and the reader, which sets it and has ContinueRunExecuteReaderTdsAsync clear it. Use one disposable scope created at reader entry.
Shorten ContinueRunExecuteReaderTdsAsync (16 parameters). Group the prepared connection,
close count, database and retry connection into a struct with one Validate(method) method,
replacing the repeated ValidateConnectionLifetime + ValidateConnectionForEnclaveExecution
pairs.
Simplify SqlCommand.CreateLocalCompletionTask: pull out a ShouldRetry(exception, usedCache) helper instead of reaching the catch block through task.GetAwaiter().GetResult(),
and turn the ContinueWith(async ...) lambda into a named async method.
Replace the three catch blocks in SqlCommand.GenerateEnclavePackage with one catch
that uses an exception filter.
Move the setup shared by the SimulatedServer pending-package-key tests in SqlCommandEnclaveAsyncTests into a helper.
Existing unit and SimulatedServer tests should pass unchanged.
This is a refactoring task that follows the five-layer split of async Always Encrypted support (#3672). It simplifies state ownership of _enclaveAttestationInProgress, the ContinueRunExecuteReaderTdsAsync signature, SqlCommand.CreateLocalCompletionTask retry handling, and GenerateEnclavePackage exception handling. Severity is P3: no behavior change is intended. The main risk is subtle changes to async state and retry semantics.
Next Steps
Assign to Copilot coding agent or the existing assignee. Do the five checklist items as separate, reviewable commits, and keep the existing unit and SimulatedServer tests unchanged and passing.
Make the in-progress flag scope exception-safe and make sure it is released on every path (sync, async, hand-off, and retry).
Cover both sync and async paths, and re-run the enclave retry tests that exercise the cache-miss/retry flow.
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.
Activity
github-actions commentedon Nov 18, 2026
🔍 Triage Summary
Area\Async(alsoArea\Always Encrypted, already applied)Analysis
This is a refactoring task that follows the five-layer split of async Always Encrypted support (#3672). It simplifies state ownership of
_enclaveAttestationInProgress, theContinueRunExecuteReaderTdsAsyncsignature,SqlCommand.CreateLocalCompletionTaskretry handling, andGenerateEnclavePackageexception handling. Severity is P3: no behavior change is intended. The main risk is subtle changes to async state and retry semantics.Next Steps