-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-5589 add option to prefer TCP for SRV lookup #1625
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Check for the environment variable MONGOC_SRV_PREFER_TCP=ON. Option is deliberately undocumented. This option is not portable among drivers. This option does not apply to the implementation using `res_search`
vector-of-bool
approved these changes
Jun 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
eramongodb
reviewed
Jun 4, 2024
eramongodb
approved these changes
Jun 4, 2024
@@ -383,6 +383,14 @@ mongoc_topology_new (const mongoc_uri_t *uri, bool single_threaded) | |||
#endif | |||
|
|||
topology = (mongoc_topology_t *) bson_malloc0 (sizeof *topology); | |||
// Check if requested to use TCP for SRV lookup. | |||
{ | |||
char *MONGOC_EXPERIMENTAL_SRV_PREFER_TCP = _mongoc_getenv ("MONGOC_EXPERIMENTAL_SRV_PREFER_TCP"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char *MONGOC_EXPERIMENTAL_SRV_PREFER_TCP
-> char *srv_prefer_tcp
(not a macro).
kevinAlbs
added a commit
that referenced
this pull request
Jun 4, 2024
Check for the environment variable `MONGOC_EXPERIMENTAL_SRV_PREFER_TCP`. Option is documented as experimental and subject to change. This option is not portable among drivers. This option does not apply to the implementation using `res_search`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add option to prefer TCP for SRV lookup.
Checks for the environment variable
MONGOC_SRV_PREFER_TCP=ON
.Verified with this patch build.
Background & Motivation
See DRIVERS-2919 for a description of the problem this is intended to solve. DRIVERS-2919 proposes a solution for all drivers. This PR is intended as a libmongoc-only solution for the problem impacting HELP-59749.
Rejected alternatives
Adding an option setter
Initially considered was adding an option setter:
SRV lookup first occurs in
mongoc_client_pool_new_with_error
. An option setter likemongoc_client_pool_set_ssl_opts
requires a client pool to already be constructed.Adding a new constructor
Also considered was a new
mongoc_client_pool_new_with_opts
constructor and new options struct:However, this breaks established patterns for passing options to the client pool. I prefer to avoid a significant API addition.
Adding a URI option
Also considered was adding a URI option
srvPreferTCP
. This may result in a non-portable URI connection string. URIs are intended to be portable among drivers: