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: Deprecate top-level write concern option keys #2624

Merged

Conversation

HanaPearlman
Copy link
Contributor

@HanaPearlman HanaPearlman commented Nov 17, 2020

This PR is mostly documentation changes to indicate that keys w, j, wtimeout and fsync are deprecated.

Code changes include:

  • WriteConcern.fromOptions now warns when the options contain the top-level keys and not the writeConcern key.
  • During client creation, when creating options from a URL, the write concern options are moved under the writeConcern key, so that warnings are not logged later. Options passed directly to the client are also moved under the writeConcern key, but only after WriteConcern.fromOptions is called, ensuring at least one warning is logged.
  • GridFS now includes options.writeConcern, if it exists, when getting the write concern.

Tests now spit out a ton of warns because the vast majority of tests which pass write concern options to client/operations use the top level keys.

@HanaPearlman HanaPearlman force-pushed the NODE-1722/3.6/deprecate-wc-options branch 2 times, most recently from 15cd47d to a5362ff Compare November 18, 2020 14:56
@HanaPearlman HanaPearlman changed the title feat: Deprecate top-level write concern option keys (w, j, wtimeout) feat: Deprecate top-level write concern option keys Nov 18, 2020
@HanaPearlman HanaPearlman force-pushed the NODE-1722/3.6/deprecate-wc-options branch from 2ef376f to 0818bd8 Compare November 18, 2020 15:23
@HanaPearlman HanaPearlman marked this pull request as ready for review November 18, 2020 15:34
@HanaPearlman HanaPearlman force-pushed the NODE-1722/3.6/deprecate-wc-options branch 2 times, most recently from 19bbd0c to 0b2c24d Compare November 19, 2020 16:03
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

looking mostly good!
As the for the test output sometime it turns into a WALL of deprecations 😆
I'd take a look at test/tools/runner/config.js:225 specifically the writeConcernMax method and see if changing that to the correct format will clean most of it up.

lib/write_concern.js Show resolved Hide resolved
* @param {(number|string)} [options.w] DEPRECATED: The write concern. Use writeConcern instead.
* @param {number} [options.wtimeout] DEPRECATED: The write concern timeout. Use writeConcern instead.
* @param {boolean} [options.j=false] DEPRECATED: Specify a journal write concern. Use writeConcern instead.
* @param {boolean} [options.fsync=false] DEPRECATED: Specify a file sync write concern. Use writeConcern instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

https://docs.mongodb.com/manual/reference/write-concern/index.html
Fsync isn't an option anymore, its equivalent to journal, maybe this is a good opportunity to write a message: "since version x use journal instead"

@@ -760,7 +760,7 @@ describe('Bulk', function() {
batch.insert({ b: 1 });

// Execute the operations
batch.execute(self.configuration.writeConcernMax(), function(err, result) {
batch.execute(self.configuration.writeConcernMax().writeConcern, function(err, result) {
expect(err).to.exist;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

writeConcernMax was changed to return a writeConcern formatted the new way-- writeConcern: {w:1, ...}. Bulk execute takes an actual WriteConcern object as its first parameter (this was changed in master), so we have to un-wrap the writeConcernMax result here.

}

return { w: 1 };
return { writeConcern: { w: 1 } };
}

Copy link
Contributor Author

@HanaPearlman HanaPearlman Nov 19, 2020

Choose a reason for hiding this comment

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

Per @nbbeeken 's suggestion. The benefit of making this change should be about half as many warnings during testing.

Copy link
Contributor

@emadum emadum left a comment

Choose a reason for hiding this comment

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

LGTM 👍

One minor issue, Db.prototype.dropDatabase doesn't have writeConcern documented as an option but I think it does support it. While I don't think it needs to hold up this PR, we should probably go through and audit the Collection/Db objects to make sure all commands that support writeConcern have it listed in the jsdoc.

@wolrajhti
Copy link

Hi everyone, it seems that the new format for writeConcern options is not used everywhere in the driver (I think at least in ./lib/utils.js#mergeOptionsAndWriteConcern). So even when we pass the new format, we still get the depreciation message over and over.

https://jira.mongodb.org/browse/NODE-3114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants