David Walschots
unread,10 Apr 2012, 1:57:14 pm10/04/12Sign in to reply to author
Sign in to forward
You don’t have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the ‘view member email addresses’ permission to view the original message
to mongodb-user
Consider two concurrently updates (U1, U2), structured as follows:
db.foo.update(
{ state : 1, players: { $size: 2 } } ,
{ $push: { players : { new player document } }, $set { state : 2 } },
false , true );
I don't want these updates to interfere with each other at the
document level. I.e. if U1 has updated document #1, then document #1
no longer matches the query part of update U2 and therefore should not
be modified.
My question is if the following (unwanted) sequence is possible, and
if so how this situation can be mitigated?
U1 finds that document #1 matches the query portion of the update
statement.
U2 finds that document #1 matches the query portion of the update
statement.
U1 pushes a new player in document #1.
U2 pushes a new player in document #1.
The end result is that document #1 contains one more player than
expected, because both U1 and U2 were under the impression that
document #1 contains only two players.
Thank you for your help.
Kind regards,
David Walschots