Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DNS Check Interval connection string option #1201

Closed
bgrainger opened this issue Aug 12, 2022 · 2 comments
Closed

Add DNS Check Interval connection string option #1201

bgrainger opened this issue Aug 12, 2022 · 2 comments
Assignees
Milestone

Comments

@bgrainger
Copy link
Member

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.

@bgrainger bgrainger added this to the 2.2 milestone Aug 19, 2022
@bgrainger bgrainger changed the title Add DNS Recheck Seconds connection string option Add DNS Check Interval connection string option Sep 18, 2022
@bgrainger bgrainger self-assigned this Sep 18, 2022
@bgrainger
Copy link
Member Author

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.

@bgrainger
Copy link
Member Author

Added in 2.2.0.

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

No branches or pull requests

1 participant