Closed ossinkine closed 3 years ago
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.
@alcaeus passing w
option in DocumentManager::flush
or specifying in Document annotation also does not work. What is a true way to pass it?
The true way is to pass a write concern option:
$dm->flush(['writeConcern' => new \MongoDB\Driver\WriteConcern('majority')])
Looks like this method should be removed or refactored because it works wrong and consfusing
You've found the source of the problem. Want to create a PR to fix the issue? :)
Yes I can if you describe the correct behavior in your opinion
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.
@alcaeus Please tell which base branch I should use to fix
2.2.x is our current branch for bug fixing. Thanks!
Fixed in #2294.
Bug Report
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 indoctrine_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 toMongoDB\Collection::updateOne
which never useww
key, it expectswriteConcern
key with object instance ofMongoDB\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 inmongodb/mongodb
.Expected behavior
WriteConcern correctly passes info
mongodb/mongodb
and exists in request.