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

fix(schema): avoid applying default write concern to operations that are in a transaction #14391

Merged
merged 1 commit into from Feb 29, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #11382

Summary

You aren't supposed to set write concern on operations in a transaction, rather set writeConcern on the transaction as a whole:

image

This PR makes it so that Mongoose doesn't apply schema-level write concern to operations that are within a transaction

Examples

@vkarpov15 vkarpov15 added this to the 8.2.1 milestone Feb 28, 2024
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

Looks good, should the same be done for read-concern?

Transactions and Available Read Concerns

For multi-document transactions, you set the read concern at the transaction level, not at the individual operation level. The operations in the transaction will use the transaction-level read concern. Any read concern set at the collection and database level is ignored inside the transaction. If the transaction-level read concern is explicitly specified, the client level read concern is also ignored inside the transaction.

Do not explicitly set the read concern for the individual operations. To set the read concern for transactions, see Read Concern/Write Concern/Read Preference.

source

@vkarpov15
Copy link
Collaborator Author

We don't have support for schema-level read concern option, so this is a non-issue for read concerns currently.

@vkarpov15 vkarpov15 merged commit 4b34967 into master Feb 29, 2024
34 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-11382 branch March 1, 2024 12:32
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.

MongoError: writeConcern is not allowed within a multi-statement transaction
2 participants