-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(NODE-3467): implement srvMaxHosts, srvServiceName options #3031
Conversation
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.
Some feedback just on the helpers
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.
More feedback on just the shuffle portion
b74b277
to
1d09e18
Compare
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.
just some wording clean up on the shuffle
Co-authored-by: Daria Pardue <[email protected]>
make use of timers and await IO
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.
Just capturing some thoughts before I move on to looking at more of this
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.
Thoughts on srvMaxHosts specifically
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.
More notes
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.
Still have tests to review, but here's more feedback
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.
Some feedback on just the code, maybe hopefully the last round, still need to look at the tests
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.
URI spec test portion comments
test/unit/connection_string.test.js
Outdated
// TODO(): srvMaxHost limiting happens in the callback given to resolveSRVRecord inside the driver | ||
// How can we test this in unit test? | ||
|
||
// if (options.srvHost && comment.includes('srvMaxHosts')) { |
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.
Just a note but it's potentially one way to add a check... Could be that we test that the list of hosts after the randomisation is equal to the list of server description host names in the created topology? Just thinking aloud.
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.
Moved these tests to initial_dns_seedlist_discovery.spec.test.ts to go along with our nice naming convention but also skipped them due to needing more concrete assertions around the error cases. And it is tracked here: NODE-3757
@dariakp I went through and made sure I addresses all your current comments. |
src/sdam/topology.ts
Outdated
const selectedHosts = | ||
options.srvMaxHosts === 0 || options.srvMaxHosts >= seedlist.length | ||
? seedlist | ||
: shuffle(seedlist, options.srvMaxHosts); |
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.
I moved the initial shuffling to here, in order to unit test since the callback to resolveSRVRecord is inaccessible to the tests.
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.
seems like that works too
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.
Some comments while I look at the tests
Co-authored-by: Daria Pardue <[email protected]>
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.
Just to summarize what we discussed - we want to pull in the spec changes associated with test 13, which involve NODE-3450 along with the changes that would have been done in NODE-3680; we also want to make the mock tests more closely resemble the prose tests as written, and we want to break out the seed discovery tests into their own file and see if they can run as integration tests.
test/integration/polling-srv-records-for-mongos-discovery/spec_prose.test.ts
Outdated
Show resolved
Hide resolved
test/unit/polling_srv_records_for_mongos_discovery.prose.test.ts
Outdated
Show resolved
Hide resolved
test/unit/polling_srv_records_for_mongos_discovery.prose.test.ts
Outdated
Show resolved
Hide resolved
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 and fine with implementing NODE-3757 later.
Description
What is changing?
A new option
srvMaxHosts
is now implemented that enables a user to limit the number of mongoses the driver will connect to. The driver will select from the list of hosts returned by a DNS lookup at random using the Fisher-Yates algorithm.The
srvServiceName
allows the srv address prefix to be changed from the default ofmongodb
Is there new documentation needed for these changes?
There is new TSDoc, I don't think further documentation will be needed.
What is the motivation for this change?
The number of mongos hosts can be large and each gets its own connection pool, it allows for tuning of how many query routers a driver connects to, primarily in order to manage networking resources.
Double check the following
npm run check:lint
script<type>(NODE-xxxx)<!>: <description>