I use multiple processes, which run in parallel to update date in a MongoDb collection. I use something like this:
db.collection.bulkWrite(
[
{ updateOne : <document> },
{ updateOne : <document> },
{ updateOne : <document> },
{ updateOne : <document> },
],
{ ordered : false }
)
The updateOne query often update the same document, but within the document different trees. My query looks something like this:
{
'_id': 'ABC12345',
'idents.tree.subtreeId': $anyIdHere,
}
and the set for the update:
{ '$set': {
'idents.$.tree.entry': $newDictHere,
} }
If two processes now execute bulkWrite on the same document (i.e. ABC12345), but for different subtreeIds, the first bulkWrite and its updateOnes are not persisted in the document. Looks like there is a concurrency issue, but I do not know what is causing it. Are there any MongoDb limitations I might be missing? I use pymongo any Python to execute the bulkWrite.