-
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-6392): add timeoutMS support to ClientEncryption helpers part 1 #4281
Conversation
d224fff
to
c3f31da
Compare
aed4450
to
1744150
Compare
c3f31da
to
4fd4b24
Compare
36db2ab
to
629b284
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 test questions!
// AutoEncrypter is made inside of MongoClient constructor while options are being parsed, | ||
// we do not have access to the options that are in progress. | ||
// TODO(NODE-NODE-6449): AutoEncrypter does not use client options for autoSelectFamily | ||
Object.assign(clientOptions, autoSelectSocketOptions(this._client.s?.options ?? {})); |
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'm not opposed to adjusting our usages of client.options
to client.s.options
but unless we have some sort of mechanism of enforcing it, I worry that its a losing battle and that usages of client.options
will slip in (like many imports from bson
got past us in review until we linted for it).
If this is something we care about - maybe we could defer this and see if we can write a lint rule? We could probably do this with a typescript-eslint plugin.
Or deprecate options
in favor of a non-Object.freeze() getter and then switch to the other getter?
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.
Unlike the BSON import which is just a 'nice-to-have' single location for all BSON interactions, the options getter on the client has real cost spreading and freezing on every access, we fixed a ~10% performance regression when we reverted its introduction to the Session constructor, so it is worth correcting it where we notice it.
I do agree though we should be able to remove the s.options and change the getter to just storing the options directly on the client without breaking anything.
This specific case is a bug: https://jira.mongodb.org/browse/NODE-6449
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 did consider making these changes to main, but most of the usages are introduced for CSOT, maybe this will close the small gap in perf we saw. fyi: @W-A-James
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 don't understand how this fixes the bug you reported. We still instantiate an auto encrypter before adding the options to client.s
- all you've done is explicitly default to {}.
Unlike sessions, none of the places you fixed in this PR are hot code paths (this usage included). I disagree that this is burning and that important. I'm trying to say that, if you believe this needs to be addressed, please file a ticket for it so we can fix it somehow and put guardrails around this so we can't make this mistake. Otherwise more usages of client.options
will continue to pop up (for example - there are literally more occurrences of this in Aditi's PR).
edit: except cursors
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 don't understand how this fixes the bug you reported.
Because it doesn't! 😄 The ticket I filed is for us to fix the bug, I did change the code to be explicit as a reminder for anyone who drops by this line of code.
there are literally more occurrences of this in Aditi's PR
We should change the occurrences we can catch because of what we know to be true about the cost of using the incorrect API rather than giving up any attempt to improve what we are implementing.
I filed a ticket to fix this particular bug but at that time we can make sure we're not making the same mistake elsewhere and potentially lint or just correct the API altogether
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.
Is there a ticket to either 1. find a tooling solution to prevent us from using client.options
or 2. remove the freeze or 3. some other fix that ensures we don't make that mistake going forward?
test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts
Outdated
Show resolved
Hide resolved
c15cc17
to
f41917e
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 a minor test title fix
ef9994f
to
a0a0637
Compare
Description
What is changing?
Is there new documentation needed for these changes?
No
What is the motivation for this change?
The timeoutMS setting given to CE will now be passed to the various helpers.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript