-
Notifications
You must be signed in to change notification settings - Fork 312
Description
Describe the bug
When a server instance goes down or comes under heavy load, it can begin timing out on prelogin requests. As long as these timeouts take less than the user-configured connection timeout, the driver will keep retrying until the connection timeout is reached. If the driver was routed to the server by a gateway or AOAG listener, these retries are against the routed location. The driver does not return to the gateway for fresh routing instructions.
Relates to #3527
To reproduce
To reliably reproduce, requires a custom server instance where arbitrary delays can be injected.
Set up a gateway or AOAG listener and route it to a custom sql server instance.
On the server, inject a delay of 10s on prelogin.
Connect to the server with the following options:
ConnectTimeout = 30
ConnectRetryInterval = 1
Observe that multiple connection attempts are made and that each attempt targets the server and does not return to the gateway.
Expected behavior
Upon encountering any connection error, the driver should return to the gateway or listener to be routed from scratch.
Further technical details
Microsoft.Data.SqlClient version: 5.1, 6.0, 6.1
.NET target: all targets
SQL Server version: any
Operating system: any