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

feat(NODE-5682): set maxTimeMS on commands and preempt I/O #4174

Merged
merged 24 commits into from
Jul 26, 2024

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Jul 11, 2024

Description

What is changing?

  • add timeoutMS option to onData helper. Makes the iterator throw the same way an error event would.
  • Add maxTimeMS field to commands when CSOT is enabled
  • If minRoundTrip defined, add it to the timeoutContext
  • listDatabases and runCommand respect timeoutMS settings
Is there new documentation needed for these changes?

No

What is the motivation for this change?

Part of the goal of CSOT. This enables the actual interruption of operations, and hints to the server (through maxTimeMS) how long it should permit an operation to run for.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken changed the title NODE-5682-maxTimeMS WIP feat(NODE-5682): set maxTimeMS Jul 11, 2024
@nbbeeken nbbeeken requested a review from W-A-James July 11, 2024 15:46
@nbbeeken nbbeeken force-pushed the NODE-5682-maxTimeMS branch from dca1a9c to 723e160 Compare July 11, 2024 18:55
@W-A-James W-A-James removed their request for review July 19, 2024 18:02
@nbbeeken nbbeeken force-pushed the NODE-5682-maxTimeMS branch from de93db9 to 4c04b2a Compare July 22, 2024 15:22
@nbbeeken nbbeeken force-pushed the NODE-5682-maxTimeMS branch from 4c04b2a to 7c79517 Compare July 23, 2024 17:59
@nbbeeken nbbeeken changed the title WIP feat(NODE-5682): set maxTimeMS feat(NODE-5682): set maxTimeMS on commands and preempt I/O Jul 23, 2024
@nbbeeken nbbeeken marked this pull request as ready for review July 23, 2024 18:54
@baileympearson baileympearson self-assigned this Jul 24, 2024
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 24, 2024
src/cmap/connection.ts Show resolved Hide resolved
@@ -416,6 +417,11 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
...options
};

if (options.timeoutContext?.csotEnabled()) {
const { maxTimeMS } = options.timeoutContext;
if (maxTimeMS > 0 && Number.isFinite(maxTimeMS)) cmd.maxTimeMS = maxTimeMS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why this logic is necessary - if the remaining timeoutMS is less than minRoundTripTime, we're supposed to throw and exit. So maxTimeMS should never be negative here - right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but this is a check for greater than 0, so it confirms that maxTimeMS does not equal 0. The checks for if we should throw are colocated with the write/read steps.

src/cmap/connection.ts Show resolved Hide resolved
src/cmap/connection.ts Outdated Show resolved Hide resolved
src/sdam/server.ts Outdated Show resolved Hide resolved
src/sdam/topology.ts Show resolved Hide resolved
src/timeout.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken requested a review from baileympearson July 24, 2024 17:29
src/cmap/connection.ts Show resolved Hide resolved
src/timeout.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken requested a review from baileympearson July 25, 2024 17:57
@baileympearson baileympearson merged commit 7baefd1 into NODE-6090 Jul 26, 2024
26 checks passed
@baileympearson baileympearson deleted the NODE-5682-maxTimeMS branch July 26, 2024 13:55
nbbeeken added a commit that referenced this pull request Aug 13, 2024
nbbeeken added a commit that referenced this pull request Aug 20, 2024
nbbeeken added a commit that referenced this pull request Aug 21, 2024
nbbeeken added a commit that referenced this pull request Sep 12, 2024
nbbeeken added a commit that referenced this pull request Sep 25, 2024
nbbeeken added a commit that referenced this pull request Sep 27, 2024
baileympearson pushed a commit that referenced this pull request Oct 1, 2024
baileympearson pushed a commit that referenced this pull request Oct 1, 2024
W-A-James added a commit that referenced this pull request Oct 1, 2024
W-A-James added a commit that referenced this pull request Oct 1, 2024
baileympearson pushed a commit that referenced this pull request Oct 10, 2024
nbbeeken added a commit that referenced this pull request Oct 14, 2024
baileympearson pushed a commit that referenced this pull request Oct 21, 2024
nbbeeken added a commit that referenced this pull request Nov 1, 2024
nbbeeken added a commit that referenced this pull request Nov 5, 2024
dariakp pushed a commit that referenced this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants