Skip to content

feat(config): add MultiSubnetFailover support - #15

Merged
MattJackson merged 1 commit into
devfrom
feat/multi-subnet-failover
Aug 29, 2026
Merged

MattJackson merged 1 commit into
devfrom
feat/multi-subnet-failover

Conversation

@MattJackson

Copy link
Copy Markdown
Owner

Integrates upstream prisma/tiberius#378 (resolves #337, supersedes #357) onto current dev.

What

  • Adds a multi_subnet_failover field to Config with a multi_subnet_failover(bool) setter and get_multi_subnet_failover() getter (defaults to false).
  • Parses the MultiSubnetFailover keyword from both ADO.NET and JDBC connection strings via the shared ConfigString trait, using the existing parse_bool helper (accepts true/false/yes/no).
  • When enabled, the SQL Browser connect_named implementations for tokio, async-std and smol now connect to every resolved address in parallel with FuturesUnordered and return the first successful stream; when disabled they keep the previous sequential behaviour.
  • Factors the per-address connect/SSRP logic into a connect_addr helper in each backend and preserves the first observed error rather than masking it with a generic "Could not resolve server host".
  • Documents the new public API and adds the keyword to the ADO connection-string doc table.

Reconciliation with current dev

  • Slots into dev's Config/ConfigString plumbing without disturbing the TDS 8.0 strict encryption path: the parallel address selection happens while establishing the TcpStream (in SqlBrowser::connect_named), before Client::connect/Connection::connect, which continue to receive an already-connected stream. Doc comments on those constructors now note this.
  • No dependency changes.

Verification

  • cargo build (default features): passes.
  • cargo test --lib and cargo test --features=all --lib: pass, including the new parsing tests (multi_subnet_failover_parsing, multi_subnet_failover_parsing_missing, multi_subnet_failover_from_ado_string).
  • cargo clippy --features=all: introduces no new lints in the touched code (pre-existing lints from newer stable toolchain are unrelated).
  • cargo fmt: clean.

Opened as a draft because the runtime parallel-connect failover behaviour can only be exercised against a live multi-subnet SQL Server (e.g. an Always On availability group listener) with the SQL Browser; the config/connection-string surface is fully unit-tested.

🤖 Generated with Claude Code

Integrate upstream PR #378 (resolves #337). Add a `multi_subnet_failover`
option to `Config` with a setter/getter and ADO/JDBC connection-string
parsing of the `MultiSubnetFailover` keyword (via the shared `ConfigString`
trait, so it works for both string formats).

When enabled, the SQL Browser `connect_named` paths (tokio, async-std, smol)
attempt connections to every resolved address in parallel using
`FuturesUnordered` and return the first stream to succeed; otherwise they
fall back to the existing sequential behaviour. The per-address connect
logic is factored into a `connect_addr` helper, and the first observed
error is now preserved instead of being masked by a generic "not found".

Adds unit tests for keyword parsing and end-to-end `from_ado_string`
propagation.
@MattJackson
MattJackson merged commit 27239c0 into dev Aug 29, 2026
@MattJackson
MattJackson deleted the feat/multi-subnet-failover branch August 29, 2026 21:33
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