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

Schema with writeConcern set results in createIndex triggering "top-level use of w, wtimeout" deprecation notice #10083

Closed
unusualbob opened this issue Mar 31, 2021 · 7 comments · Fixed by #10167
Labels
help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary

Comments

@unusualbob
Copy link
Contributor

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Having a schema with write concern results in a deprecation notice for each index creation for that schema.

If the current behavior is a bug, please provide the steps to reproduce.
Schema options: { writeConcern: { w: 1 } } with at least one indexed field

What is the expected behavior?
Should have no deprecation notice due to new format

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node v12.20.2
Mongoose 5.11.20
Mongodb 3.4

Additional Notes
This is appears to be a different codepath than #10009
On a side note, there also appears to be an issue with the mongodb-native-driver giving erroneous deprecation notices for writeConcern specifically, so I've got a PR open there. mongodb/node-mongodb-native#2773

@IslandRhythms
Copy link
Collaborator

I believe this was fixed on the most recent version of mongoose

@ChoppinBlockParty
Copy link

I am not sure that is was fully fixed, see #10009 (comment).

@sibelius
Copy link
Contributor

I've got the full stack trace of warning

(node:71419) [MONGODB DRIVER] Warning: Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
  at emitWarning (/app/node_modules/mongodb/lib/utils.js:844:17)
at Object.emitWarningOnce (/app/node_modules/mongodb/lib/utils.js:863:12)
at Function.fromOptions (/app/node_modules/mongodb/lib/write_concern.js:82:11)
at resolveWriteConcern (/app/node_modules/mongodb/lib/operations/command_v2.js:112:23)
at new CommandOperationV2 (/app/node_modules/mongodb/lib/operations/command_v2.js:25:25)
at new CreateIndexesOperation (/app/node_modules/mongodb/lib/operations/create_indexes.js:46:5)
at Collection.createIndex (/app/node_modules/mongodb/lib/collection.js:1247:34)
at NativeCollection.<computed> [as createIndex] (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:218:28)
  at NativeCollection.create (/app/node_modules/mongoose/lib/model.js:1667:33)
  at NativeCollection.Collection.doQueue (/app/node_modules/mongoose/lib/collection.js:137:17)
  at /app/node_modules/mongoose/lib/collection.js:82:24
  at processTicksAndRejections (internal/process/task_queues.js:75:11)

mongoose: 5.12.3

@IslandRhythms IslandRhythms linked a pull request Apr 21, 2021 that will close this issue
@IslandRhythms IslandRhythms added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed seen labels Apr 21, 2021
@vkarpov15 vkarpov15 added this to the 5.12.6 milestone Apr 23, 2021
vkarpov15 added a commit that referenced this issue Apr 26, 2021
@hillct
Copy link

hillct commented Jun 4, 2021

It appears that this issue persists, in Mongoose 5.12.13 yielding the following stack trace:

(node:9572) [MONGODB DRIVER] Warning: Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
at emitWarning (node_modules/mongoose/node_modules/mongodb/lib/utils.js:851:17)
at Object.emitWarningOnce (node_modules/mongoose/node_modules/mongodb/lib/utils.js:870:12)
at Function.fromOptions (node_modules/mongoose/node_modules/mongodb/lib/write_concern.js:82:11)
at applyWriteConcern (node_modules/mongoose/node_modules/mongodb/lib/utils.js:457:37)
at removeDocuments (node_modules/mongoose/node_modules/mongodb/lib/operations/common_functions.js:281:18)
at DeleteManyOperation.execute (node_modules/mongoose/node_modules/mongodb/lib/operations/delete_many.js:22:5)
at node_modules/mongoose/node_modules/mongodb/lib/operations/execute_operation.js:72:19
at maybePromise (node_modules/mongoose/node_modules/mongodb/lib/utils.js:692:3)
at executeOperation (node_modules/mongoose/node_modules/mongodb/lib/operations/execute_operation.js:34:10)
at Collection.deleteMany (node_modules/mongoose/node_modules/mongodb/lib/collection.js:972:10)
at Timeout._onTimeout (node_modules/connect-mongo/build/main/lib/MongoStore.js:151:59)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)

also mentioned in the race is connect-mongo which is at 4.4.1 bu it's not clear to me that's material to this issue - included here for completeness.

@IslandRhythms
Copy link
Collaborator

IslandRhythms commented Jun 4, 2021

Could you please provide the repro script you are using to get that warning

@IslandRhythms IslandRhythms added needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue and removed confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. labels Jun 4, 2021
@IslandRhythms IslandRhythms reopened this Jun 4, 2021
@hillct
Copy link

hillct commented Jun 4, 2021

I don't currently have a minimum viable example reproducing this issue. I'll see about stripping down our codebase to something that can be released for this purpose, over the weekend.

UPDATE: I wasn't able to allocate time to this over the weekend. I'm currently targeting Wednesday to work on an minimalist example. From the trace, I'm guessing it relates to external use of the Mongoose client promise (which is what connect-mongo is doing).

@vkarpov15 vkarpov15 modified the milestones: 5.12.6, 5.12.14 Jun 7, 2021
@vkarpov15
Copy link
Collaborator

@hillct this is an issue with connect-mongo, here's the relevant source code: https://github.com/jdesboeufs/connect-mongo/blob/6ba9af7978b5a745a501ab7faf55d1d563d876c9/src/lib/MongoStore.ts#L235-L239 . TLDR; connect-mongo is using top-level w and j with deleteMany(), so you should open an issue with the connect-mongo package.

@vkarpov15 vkarpov15 removed this from the 5.12.14 milestone Jun 9, 2021
@vkarpov15 vkarpov15 added help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary and removed needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue labels Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants