Skip to content

Restore legacy failover login alternation by default - #5138

Open
paulmedynski wants to merge 3 commits into
dotnet:mainfrom
paulmedynski:dev/automation/50263-failover-login
Open

paulmedynski wants to merge 3 commits into
dotnet:mainfrom
paulmedynski:dev/automation/50263-failover-login

Conversation

@paulmedynski

@paulmedynski paulmedynski commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Restore the default of Switch.Microsoft.Data.SqlClient.UseLegacyFailoverAlternationOnLoginSqlErrors to true. This restores partner alternation when a login-phase SQL error is returned by a mirror/non-readable secondary. Explicit false retains the login-error guard introduced in #4140; existing terminal authentication-error and timeout stop conditions remain unchanged.

Add simulator coverage for default/explicit switch settings, pooling, synchronous/asynchronous opens, primary retries, and terminal authentication rejection. Add opt-in real-server BAG and database-mirroring theories to the existing ManualTests suite. The adjacent README records the historical regression evidence, topology limitations, and execution instructions; build and feature documentation are updated. No public API changes, new connection-string keywords, localization changes, or pipeline changes.

Lab provisioning lives separately in the dotnet/sqlclient-samples repository, under FailoverLab/, supplied by companion dotnet/sqlclient-samples#2. The lab provides Linux Basic AG and Windows database-mirroring setup and runners for these opt-in ManualTests. No separate failover project or executable historical-package comparison capability is included.

Suggested release note: Restore default Failover Partner alternation after login-phase SQL errors, fixing a 7.1 regression affecting database mirroring and the reported listenerless Basic AG deployment.

  • Tests added or updated
  • Public API changes documented (no public API changes)
  • Verified against customer repro (diagnostic BAG and genuine mirroring labs verified; exact customer WSFC topology not reproduced)
  • Ensure no breaking changes introduced (restores prior default behavior; explicit false remains available)

Issues

Fixes #5029.

Related investigation: ADO.Net work item 50263. Regression introduced by #4140.

Testing

Validation on this GitHub-main-based branch:

  • dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj --framework net10.0 --filter 'FullyQualifiedName~ConnectionFailoverTests|FullyQualifiedName~LocalAppContextSwitchesTest' --logger 'console;verbosity=minimal' --blame-hang-timeout 2m — built successfully; 74 passed, 1 failed, 0 skipped (75 total). Remaining failure: TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUserProvidedPartner.
  • env -u SQLCLIENT_BAG_TESTS -u SQLCLIENT_MIRROR_TESTS dotnet test src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj --framework net10.0 --filter 'FullyQualifiedName~BasicAvailabilityGroupFailoverTest|FullyQualifiedName~DatabaseMirroringFailoverTest' --logger 'console;verbosity=minimal' --blame-hang-timeout 2m — built successfully; both theories skipped as intended without opt-in. This establishes gating, not failover coverage.
  • bash /home/paul/dev/sqlclient-samples/dev/automation/50263-failover-lab/FailoverLab/lab.sh test with SQLCLIENT_REPO_ROOT pointing to this branch and disposable lab credentials supplied through environment variables — passed 12/12 SQL Server 2019 Linux BAG cases on .NET 10. The lab was stopped afterward with data retained.
  • git diff --check — passed.

Earlier validation of the same fix/tests before migration: Windows switch/failover units passed 259/259 across net462/net8/net9/net10; real-server three-role-phase coverage passed 144/144 checks across Linux SQL 2019/2022/2025 BAGs and Windows SQL 2019 mirroring. After suite consolidation, native Windows/.NET 10 ManualTests mirroring passed 12/12 using a temporary local checkout that was removed afterward. These earlier results are not reruns of the current GitHub-main-based branch.

Full BuildAll, full ManualTests, and native Windows mirroring on the migrated branch have not been run. Both lab theories remain opt-in/interactive and are excluded from normal orchestrated test filters. The Windows container/RTM lab is diagnostic, not evidence of an exact supported customer deployment.

Guidelines

Please review the contribution guidelines before submitting a pull request:

Fixes dotnet#5029. Add simulator and opt-in BAG/mirroring regression coverage, with recorded lab evidence and execution instructions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:09
@paulmedynski paulmedynski added this to the 8.1.0-preview1 milestone Nov 24, 2026
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 24, 2026
@paulmedynski paulmedynski moved this from To triage to In progress in SqlClient Board Nov 24, 2026
@paulmedynski paulmedynski added Regression 💥 Issues that are regressions introduced from earlier PRs. Hotfix 8.0.0 PRs that must be backported to release/8.0 Hotfix 7.1.3 PRs targeting main that should be backported to release/7.1 for 7.1.3. labels Nov 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An unconditional reference to a NET-only helper breaks net462 compilation, and reused pool state can cause later failover tests to fail despite correct driver behavior.

2 open issues
What changed in this PR

Restores legacy failover-partner alternation by default to address the login-error regression reported in #5029. Explicitly setting the compatibility switch to false preserves the guard introduced in #4140.

Changes:

  • Changes the switch default to true without changing terminal authentication-error or timeout handling.
  • Expands simulator coverage and adds opt-in Basic Availability Group and database-mirroring tests.
  • Documents lab setup, historical validation, topology limitations, and test execution.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​SimulatedServerTests/​ConnectionFailoverTests.cs Adds switch, login-error, and authentication-rejection coverage.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft/​Data/​SqlClient/​LocalAppContextSwitchesTest.cs Updates the expected switch default.
src/​Microsoft.Data.SqlClient/​tests/​ManualTests/​SQL/​MirroringTest/​README.md Documents lab requirements, execution, and regression evidence.
src/​Microsoft.Data.SqlClient/​tests/​ManualTests/​SQL/​MirroringTest/​DatabaseMirroringFailoverTest.cs Adds opt-in native Windows mirroring tests.
src/​Microsoft.Data.SqlClient/​tests/​ManualTests/​SQL/​MirroringTest/​BasicAvailabilityGroupFailoverTest.cs Adds opt-in listenerless Basic AG tests.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​LocalAppContextSwitches.cs Enables legacy alternation by default.
BUILDGUIDE.md Links to opt-in failover test instructions.
.github/​instructions/​features.instructions.md Documents the restored default and explicit opt-out.
.github/​copilot-instructions.md Updates the failover compatibility-switch description.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:23
Keep the net462 ManualTests build compatible with the modern-only UseManagedNetworking helper property.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The failover tests violate the mandatory focused-scenario rule by combining sync/async and success/rejection behaviors, requiring separate theories for those scenarios.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Low severity Split sync/async success and rejection tests into focused scenarios

src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​SimulatedServerTests/​ConnectionFailoverTests.cs:947

This theory uses flags to select Open versus OpenAsync and successful alternation versus rejection, contrary to the mandatory focused-scenario rule in .github/instructions/testing.instructions.md (Required Test Authoring Rules, item 8). Split these into separate sync/async success and rejection theories, keeping pooling and unset/true settings as inputs where the behavior is unchanged. Apply the same sync/async split to LoginFailed_WithUserProvidedPartner_ShouldNotAlternate at line 1145; its switch settings can remain theory inputs.

1 resolved since last review

Review effort: Balanced

Address dotnet#5138 review feedback with unique simulator pool keys and separate sync/async success and rejection theories. Share setup and assertions while preserving all 18 input cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human review is needed because the driver-wide failover/retry default change lacks native Windows validation, retains an unresolved unit-test failure, and has not been validated against the customer’s WSFC topology.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@paulmedynski
paulmedynski marked this pull request as ready for review November 24, 2026 14:31
@paulmedynski
paulmedynski requested a review from a team November 24, 2026 14:31
@paulmedynski
paulmedynski enabled auto-merge (squash) November 24, 2026 14:31
@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board Nov 24, 2026
@apoorvdeshmukh apoorvdeshmukh self-assigned this Nov 24, 2026

This branch has not been deployed

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

Labels

Hotfix 7.1.3 PRs targeting main that should be backported to release/7.1 for 7.1.3. Hotfix 8.0.0 PRs that must be backported to release/8.0 Regression 💥 Issues that are regressions introduced from earlier PRs.

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

"Failover Partner" connection string setting with a Basic Availability Group no longer works in 7.1.x

3 participants