-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Correctly handle write concern specified in defaultCommitOptions #2294
Conversation
116f6ac
to
e389c7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this. I've added some suggestions on how to improve the changes you've made. The tests look fine. I think we could profit from some more functional tests (e.g. insert a duplicate document with an unacknowledged write, run into a timeout waiting for the write to be acknowledged, etc.)
@@ -1493,10 +1498,17 @@ private function getWriteOptions(array $options = []): array | |||
$defaultOptions = $this->dm->getConfiguration()->getDefaultCommitOptions(); | |||
$documentOptions = []; | |||
if ($this->class->hasWriteConcern()) { | |||
$documentOptions['w'] = $this->class->getWriteConcern(); | |||
$documentOptions['writeConcern'] = new WriteConcern($this->class->getWriteConcern()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should cover us for now since the write concern option is documented as string|int|null
. We'll have to refactor the metadata handling to no longer accept a w
option alone but rather find a way to specify actual write concern objects in metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get what you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are able to specify a write concern in metadata:
@ODM\Document(writeConcern="majority")
However, there's more to a write concern than just the w
, but it also includes a wtimeout
option to specify how long you're willing to wait for the write concern to be achieved. At this time, it's not possible to specify this option, which means that we'll have to refactor this handling in general, at which point we'll no longer have to deal with w
.
What about some more tests, undoubtedly it will be much better with them, but I'm not sure this bugfix requires them. |
I believe we are good on tests for this change. I'll circle back to add more tests when the handling of write concern in metadata is fixed. |
Thanks @ossinkine! |
* Fix locking when ClassMetadata is unserialized Caching / unserializing ClassMetadata broke locking functionality Fixes #2278 * Test serialization of lock/version fields * Update working-with-objects.rst Detach doc text from code block * Update storage-strategies.rst * Fix invalid strict comparison when validating mappings * Correctly handle write concern specified in defaultCommitOptions (#2294) * Fix documentation for uploadFromFile * Fix mapping of the nullable option for XML driver * Fix query preparation when in elemMatch (#2299) * Fix preparation of $elemMatch operators in queries (#2298) * Fix using null values in partial filter expressions (#2300) * Fix errors with nullable typed associations (#2302) * Fix initialising nullable associations * Fix error when merging documents with uninitialised typed properties Co-authored-by: buffcode <buffcode@users.noreply.github.com> Co-authored-by: Laurens Stötzel <l.stoetzel@meeva.de> Co-authored-by: Maciej Malarz <malarzm@gmail.com> Co-authored-by: jeeiex <78592605+jeeiex@users.noreply.github.com> Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com> Co-authored-by: Andreas Braun <git@alcaeus.org> Co-authored-by: Gocha Ossinkine <ossinkine@ya.ru> Co-authored-by: Ryan RAJKOMAR <rrajkomar@users.noreply.github.com> Co-authored-by: wuchen90 <wu.chen@agriconomie.com> Co-authored-by: Andreas Braun <alcaeus@users.noreply.github.com>
* 2.2.x: Fix handling of upserts during scheduling for deletion (doctrine#2334) Fix wrong handling for nullable fields in upsert and update (doctrine#2318) [2.2] Fix builds (doctrine#2319) Allow mixed value in $not operator (doctrine#2307) Fix errors with nullable typed associations (doctrine#2302) Fix using null values in partial filter expressions (doctrine#2300) Fix preparation of $elemMatch operators in queries (doctrine#2298) Fix query preparation when in elemMatch (doctrine#2299) Fix mapping of the nullable option for XML driver Fix documentation for uploadFromFile Correctly handle write concern specified in defaultCommitOptions (doctrine#2294) Fix invalid strict comparison when validating mappings Update storage-strategies.rst Update working-with-objects.rst Test serialization of lock/version fields Fix locking when ClassMetadata is unserialized
* 2.2.x: Fix handling of upserts during scheduling for deletion (doctrine#2334) Fix wrong handling for nullable fields in upsert and update (doctrine#2318) [2.2] Fix builds (doctrine#2319) Allow mixed value in $not operator (doctrine#2307) Fix errors with nullable typed associations (doctrine#2302) Fix using null values in partial filter expressions (doctrine#2300) Fix preparation of $elemMatch operators in queries (doctrine#2298) Fix query preparation when in elemMatch (doctrine#2299) Fix mapping of the nullable option for XML driver Fix documentation for uploadFromFile Correctly handle write concern specified in defaultCommitOptions (doctrine#2294) Fix invalid strict comparison when validating mappings Update storage-strategies.rst Update working-with-objects.rst Test serialization of lock/version fields Fix locking when ClassMetadata is unserialized
* 2.2.x: Fix handling of upserts during scheduling for deletion (doctrine#2334) Fix wrong handling for nullable fields in upsert and update (doctrine#2318) [2.2] Fix builds (doctrine#2319) Allow mixed value in $not operator (doctrine#2307) Fix errors with nullable typed associations (doctrine#2302) Fix using null values in partial filter expressions (doctrine#2300) Fix preparation of $elemMatch operators in queries (doctrine#2298) Fix query preparation when in elemMatch (doctrine#2299) Fix mapping of the nullable option for XML driver Fix documentation for uploadFromFile Correctly handle write concern specified in defaultCommitOptions (doctrine#2294) Fix invalid strict comparison when validating mappings Update storage-strategies.rst Update working-with-objects.rst Test serialization of lock/version fields Fix locking when ClassMetadata is unserialized
* 2.2.x: Fix handling of upserts during scheduling for deletion (doctrine#2334) Fix wrong handling for nullable fields in upsert and update (doctrine#2318) [2.2] Fix builds (doctrine#2319) Allow mixed value in $not operator (doctrine#2307) Fix errors with nullable typed associations (doctrine#2302) Fix using null values in partial filter expressions (doctrine#2300) Fix preparation of $elemMatch operators in queries (doctrine#2298) Fix query preparation when in elemMatch (doctrine#2299) Fix mapping of the nullable option for XML driver Fix documentation for uploadFromFile Correctly handle write concern specified in defaultCommitOptions (doctrine#2294) Fix invalid strict comparison when validating mappings Update storage-strategies.rst Update working-with-objects.rst Test serialization of lock/version fields Fix locking when ClassMetadata is unserialized
* 2.2.x: Fix wrong assertion (doctrine#2335) Fix handling of upserts during scheduling for deletion (doctrine#2334) Fix wrong handling for nullable fields in upsert and update (doctrine#2318) [2.2] Fix builds (doctrine#2319) Allow mixed value in $not operator (doctrine#2307) Fix errors with nullable typed associations (doctrine#2302) Fix using null values in partial filter expressions (doctrine#2300) Fix preparation of $elemMatch operators in queries (doctrine#2298) Fix query preparation when in elemMatch (doctrine#2299) Fix mapping of the nullable option for XML driver Fix documentation for uploadFromFile Correctly handle write concern specified in defaultCommitOptions (doctrine#2294) Fix invalid strict comparison when validating mappings Update storage-strategies.rst Update working-with-objects.rst Test serialization of lock/version fields Fix locking when ClassMetadata is unserialized
* Fix locking when ClassMetadata is unserialized Caching / unserializing ClassMetadata broke locking functionality Fixes #2278 * Test serialization of lock/version fields * Update working-with-objects.rst Detach doc text from code block * Update storage-strategies.rst * Fix invalid strict comparison when validating mappings * Correctly handle write concern specified in defaultCommitOptions (#2294) * Fix documentation for uploadFromFile * Fix mapping of the nullable option for XML driver * Fix query preparation when in elemMatch (#2299) * Fix preparation of $elemMatch operators in queries (#2298) * Fix using null values in partial filter expressions (#2300) * Fix errors with nullable typed associations (#2302) * Fix initialising nullable associations * Fix error when merging documents with uninitialised typed properties * Allow mixed value in $not operator (#2307) * [2.2] Fix builds (#2319) * Fix wrong handling for nullable fields in upsert and update (#2318) * Comprehensively test nullable behaviour for embedOne Co-authored-by: wuchen90 <wu.chen@agriconomie.com> * Fix handling of nullable fields for upsert Co-authored-by: wuchen90 <wu.chen@agriconomie.com> * Fix handling of upserts during scheduling for deletion (#2334) * Fix handling of upserts during scheduling for deletion * Added test * Fix wrong assertion (#2335) This was uncovered by Psalm testing when merging 2.2.x up into 2.3.x. * Remove psalm-baseline.xml Co-authored-by: buffcode <buffcode@users.noreply.github.com> Co-authored-by: Laurens Stötzel <l.stoetzel@meeva.de> Co-authored-by: Maciej Malarz <malarzm@gmail.com> Co-authored-by: jeeiex <78592605+jeeiex@users.noreply.github.com> Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com> Co-authored-by: Gocha Ossinkine <ossinkine@ya.ru> Co-authored-by: Ryan RAJKOMAR <rrajkomar@users.noreply.github.com> Co-authored-by: wuchen90 <wu.chen@agriconomie.com> Co-authored-by: Fran Moreno <franmomu@gmail.com> Co-authored-by: Bernhard Schussek <bschussek@gmail.com>
* 2.2.x: Fix wrong assertion (#2335) Fix handling of upserts during scheduling for deletion (#2334) Fix wrong handling for nullable fields in upsert and update (#2318) [2.2] Fix builds (#2319) Allow mixed value in $not operator (#2307) Fix errors with nullable typed associations (#2302) Fix using null values in partial filter expressions (#2300) Fix preparation of $elemMatch operators in queries (#2298) Fix query preparation when in elemMatch (#2299) Fix mapping of the nullable option for XML driver Fix documentation for uploadFromFile Correctly handle write concern specified in defaultCommitOptions (#2294) Fix invalid strict comparison when validating mappings Update storage-strategies.rst Update working-with-objects.rst Test serialization of lock/version fields Fix locking when ClassMetadata is unserialized
Summary
Fix passing
w
option toDocumentManager::flush
or default commit options