top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Single document update in high concurrent MongoDB environment?

0 votes
483 views

In our solution we have asynchronous processes with state persistence (aka sagas) where each saga has single state document persisted in mongodb. Depending on the saga type, this document may lead to high level of concurrent updates. So, we simply introduced optimistic concurrency there to retry handling of incoming messages. But as a result of that we face very high rate of retries what results in significant performance degradation. In the past we used pessimistic locking of saga document/record when used to store state in rdbms (mssql, oracle etc). I know that at the moment there is no such feature in mongodb, but maybe it would be useful/possible to have it for single document updates? I believe this feature could simplify many solutions.

Are there any other concurrency handling options? Suggestions?

posted Feb 18, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In DEVs we upgraded to v3, but in prod we still have v2. Yes, I assume that concurrency situation will be much better cause both update and read time with WiredTiger is significantly better.

Despite that, I am still missing feature to do some atomic single document update with protection from updates from other cluster nodes. Would this feature compromise something or would have negative influence on db itself? Since with WiredTiger single document locking is used for updates, what leads to assumption that my expectation has good background.

--OR--

the update way you are proposing should work, but for further saga processing i still need to read document which i have just updated with findAndModify. Other processes may concurrently update the document and saga processing may be accidently continued multiple times. Yes, this can also be handled with update of extra flags using findAndModify, but it may introduce redundant complexity.

Asya got the point what i really need: "read-modify-write or something like that". Feature i miss is that document "read/lookup" and "write/save" could be done inside mongo client implementation where "modification" should be delegated to custom c# delegate method

answer Mar 1, 2016 by Manikandan J
Similar Questions
+3 votes

I added high number of query to a db, somehow it impact query to another db. I am using mongodb 2.6.8. Should this version of mongodb has db level lock (since 2.2)?

Is this I/O disk problem?

...