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

WriteConcern option never passes into MongoDB #2292

Closed
ossinkine opened this issue Mar 5, 2021 · 10 comments
Closed

WriteConcern option never passes into MongoDB #2292

ossinkine opened this issue Mar 5, 2021 · 10 comments
Labels
Milestone

Comments

@ossinkine
Copy link
Contributor

ossinkine commented Mar 5, 2021

Bug Report

Q A
BC Break no
Version 2.2.0

Summary

I'm sorry in advance if I've just not figured out.
I want to be sure the transaction was processed on majority replicas, I've set up w: majority option in doctrine_mongodb.default_commit_options, and try to debug where this option passed into MongoDB and did not find any cases. DocumentPersister::getWriteOptions returns ['w' => 'majority'] and then options passew to MongoDB\Collection::updateOne which never usew w key, it expects writeConcern key with object instance of MongoDB\Driver\WriteConcern.

Current behavior

WriteConcern option never passes into MongoDB.

How to reproduce

Just try to pass w as write options and check it's never used in mongodb/mongodb.

Expected behavior

WriteConcern correctly passes info mongodb/mongodb and exists in request.

@ossinkine ossinkine changed the title WriteConcern options never passes into MongoDB WriteConcern option never passes into MongoDB Mar 5, 2021
@alcaeus alcaeus added the Bug label Mar 9, 2021
@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2021

Now that you mention it...updating the commit options to use WriteConcern has completely escaped my mind when updating to the new driver. Marking as a bug and will start fixing soon.

@ossinkine
Copy link
Contributor Author

@alcaeus passing w option in DocumentManager::flush or specifying in Document annotation also does not work. What is a true way to pass it?

@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2021

The true way is to pass a write concern option:

$dm->flush(['writeConcern' => new \MongoDB\Driver\WriteConcern('majority')])

@ossinkine
Copy link
Contributor Author

Looks like this method should be removed or refactored because it works wrong and consfusing

@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2021

You've found the source of the problem. Want to create a PR to fix the issue? :)

@ossinkine
Copy link
Contributor Author

Yes I can if you describe the correct behavior in your opinion

@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2021

Instead of passing on the w key, the method you pointed out should create a WriteConcern object and trigger a deprecation to let everyone know that passing a w key is no longer supported. There are some places where ODM assumes that as default, so be sure to check those out as well. Please let me know (here or in the doctrine or Symfony-devs slacks) if you run into any problems or have questions.

@ossinkine
Copy link
Contributor Author

@alcaeus Please tell which base branch I should use to fix

@alcaeus
Copy link
Member

alcaeus commented Mar 9, 2021

2.2.x is our current branch for bug fixing. Thanks!

@alcaeus
Copy link
Member

alcaeus commented Mar 10, 2021

Fixed in #2294.

@alcaeus alcaeus closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants