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
Adding atomicSet and atomicSetArray collection strategies #1096
Conversation
58458e8
to
b8efc4e
Compare
@malarzm I was thinking that the ODM should always perform all changes to a record in one atomic query. Do you agree, or do you do you feel as though this behavior should be parameterized? |
ODM can't do all changes within one query, for instance (citing @jmikola from #1009 (comment))
but of course this in not the case with |
I'm afraid we won't be able to change existing I've been also thinking that |
@blockjon could you run your test against this PR? |
Having just quickly read through the code, it appears as if this might do the trick. I will try this today and report back my findings. |
|
||
.. note:: | ||
|
||
Only top level document can contain collection with ``atomicSet`` or |
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'd rephrase as "The atomicSet
and atomicSetArray
strategies may only be used for collections mapped directly in a top-level document." And perhaps we want to duplicate this note for the atomicSetArray
section below.
Friendly question for you all - This branch fixes a critical problem I'm faced with and I would love to use it sooner rather than later. Since I'm new to this project, I'd like to get a sense of when you feel as though it would be in a state that you feel I should attempt to integrate into my project. Should I want until this gets merged to master, or until you tag a beta 13, for example? |
* with collection update in one query we won't need the $unset | ||
*/ | ||
$this->uow->unscheduleCollectionDeletion($coll); | ||
} else { |
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.
Would it be safer swap out the else
for a separate isCollectionScheduledForDeletion()
check here? I realize UnitOfWork::scheduleCollectionOwner()
, which populates the array returned by getScheduledCollections()
, is currently only called from scheduleCollectionDeletion()
and scheduleCollectionUpdate()
; however, if that changes in the future, we're looking at a very destructive else
condition :)
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.
The elseif
was there before but I'll bring it back ;)
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.
@jwage: If we make this an elseif
again, how do you feel about a final else
condition throwing a LogicException?
@blockjon idea is to have this feature merged and tag BETA-13 then |
LGTM pending test results. @jwage: Do you have a chance to take a look at this within the next day? Ideally, we'd like to get it included in a new 1.0.0-BETA13 tag this week (to help with doctrine/DoctrineMongoDBBundle#298). |
👍 |
Adding atomicSet and atomicSetArray collection strategies
I AM EXCITED!!!!!! |
Nice work gentlemen. 👍 Scott |
👍 Nice work. |
@blockjon BETA13 is now released :) |
@malarzm This is fantastic news thank you!!!! |
@malarzm - I think you need to implement atomicSet as default where possible. I just found a bug in production that happened in only 1/100.000 cases and it was driving me nuts for weeks before I found the problem. Using pushAll and multiple queries as default is really something unexpected for me as a developer. |
@daniphp +1 on your comments there... I had the same feedback here #782 (comment) |
This is an early implementation of how
atomicSet
andatomicSetArray
could work in my opinion. There are some things that needs to be donemaybe addatomic=true
flag to mapping instead of new strategy (or change existing$set
behaviour)collection within collection with different strategiesthrow exception if used in embedded documentscc @jwage @jmikola @alcaeus @lavoiesl @blockjon
If this PR will reach its final form it will resolve #1009, #437, #1095 and #1094