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-6060): set fire-and-forget protocol when writeConcern is w: 0 #4219

Merged
merged 20 commits into from
Sep 17, 2024

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Sep 3, 2024

Description

When writeConcern.w = 0 is set on an operation that's run through OP_MSG, the driver will set moreToCome on the request so that the server will not send a response.

What is changing?

  • When an operation being run through OP_MSG has writeConcern.w === 0, the driver
    • sets the moreToCome bit on the outgoing request.
    • returns from operation execution without waiting for a server response
    • set CommandSucceededEvent.reply to { ok: 1 } regardless of server reply
  • TSDoc for WriteConcern now contains extra context.
Is there new documentation needed for these changes?

No, none other than the TSDoc changes.

What is the motivation for this change?

Support spec-defined fire-and-forget protocol.

Release Highlight

Write Operations with WriteConcern.w set to 0 trigger unacknowledged write protocol

When WriteConcern.w is set to 0 on a write operation, either through operation options or the client settings, writes will be unacknowledged by the server. This means the server will not send a response after the request is sent and therefore, the return value from the operation will not contain any information from the server, including whether the server has processed the request yet.

In addition, when command monitoring is enabled, the reply field of a CommandSucceededEvent of an unacknowledged write will always be { ok: 1 }.

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

@aditi-khare-mongoDB aditi-khare-mongoDB changed the title initial commit feat(NODE-6060): Set fire-and-forget protocol when writeConcern is w: 0 Sep 3, 2024
@aditi-khare-mongoDB aditi-khare-mongoDB changed the title feat(NODE-6060): Set fire-and-forget protocol when writeConcern is w: 0 feat(NODE-6060): set fire-and-forget protocol when writeConcern is w: 0 Sep 5, 2024
lint fix

lont fix 2
@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review September 9, 2024 20:34
@durran durran self-assigned this Sep 10, 2024
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Sep 10, 2024
src/cmap/commands.ts Outdated Show resolved Hide resolved
src/cmap/connection.ts Outdated Show resolved Hide resolved
test/integration/read-write-concern/write_concern.test.ts Outdated Show resolved Hide resolved
test/integration/read-write-concern/write_concern.test.ts Outdated Show resolved Hide resolved
test/unit/commands.test.ts Outdated Show resolved Hide resolved
src/cmap/connection.ts Outdated Show resolved Hide resolved
src/cmap/commands.ts Outdated Show resolved Hide resolved
src/cmap/connection.ts Show resolved Hide resolved
src/operations/run_command.ts Outdated Show resolved Hide resolved
src/operations/command.ts Outdated Show resolved Hide resolved
durran
durran previously approved these changes Sep 16, 2024
@durran durran added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Sep 16, 2024
@durran durran merged commit 643a875 into main Sep 17, 2024
27 of 30 checks passed
@durran durran deleted the NODE-6060/fire-and-forget branch September 17, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants