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
In a HA scenario, failover can be accomplished by updating DNS to point to the new primary server. (E.g., "DNS is updated to redirect connections to the new primary when the client reconnects" in Azure MySQL.)
MySqlConnector does not detect this, so connections can remain open (in the pool) to the old IP address, which may be a server that is now read-only. The client has to reconnect to access the new primary.
Proposal: Solve this by adding a new DNS Recheck Seconds connection string option. If this is set to a positive number, n, then every n seconds, MySqlConnector checks all hostnames for the Server option, and resolves each to its IP address(es). If any has changed, the pool is cleared, then Minimum Pool Size connections are reestablished, etc. (A more advanced implementation could clear only connections to IP addresses that are no longer returned from DNS, but that doesn't have to be in v1.)
Having a background task wake up and perform this check very frequently (e.g., every 5-10 seconds may be typical) may be overkill for infrequently-accessed servers; in that case it may be preferable to check only when an existing connection is retrieved (e.g., like Connection Lifetime). However, that kind of access pattern may not be using an HA setup in the first place. The background task may be less overhead than determining if a DNS check is necessary when opening each connection, in scenarios that open dozens of connections per second.
The text was updated successfully, but these errors were encountered:
Renaming to DNS Check Interval: "re-" in "recheck" is unnecessary; most connection string timeout options are specified in seconds; DNS TTLs are also seconds; interval implies repeated checks, so is more self-descriptive.
In a HA scenario, failover can be accomplished by updating DNS to point to the new primary server. (E.g., "DNS is updated to redirect connections to the new primary when the client reconnects" in Azure MySQL.)
MySqlConnector does not detect this, so connections can remain open (in the pool) to the old IP address, which may be a server that is now read-only. The client has to reconnect to access the new primary.
Proposal: Solve this by adding a new
DNS Recheck Seconds
connection string option. If this is set to a positive number, n, then every n seconds, MySqlConnector checks all hostnames for theServer
option, and resolves each to its IP address(es). If any has changed, the pool is cleared, thenMinimum Pool Size
connections are reestablished, etc. (A more advanced implementation could clear only connections to IP addresses that are no longer returned from DNS, but that doesn't have to be in v1.)Having a background task wake up and perform this check very frequently (e.g., every 5-10 seconds may be typical) may be overkill for infrequently-accessed servers; in that case it may be preferable to check only when an existing connection is retrieved (e.g., like
Connection Lifetime
). However, that kind of access pattern may not be using an HA setup in the first place. The background task may be less overhead than determining if a DNS check is necessary when opening each connection, in scenarios that open dozens of connections per second.The text was updated successfully, but these errors were encountered: