I have n number of services running and they are all connecting to same db … and I want to implement a lock kind of mechanism in mongo db How can I do that?
I have a collection which contains some documents I want only one services should read a document at a time lock it so other process wont pick that document again. What is the better and correct way of doing this.
Currently I am using findAndModify… as soon as 1 process will pick(it will get by criteria if status is waiting) a document it will change the status filed of that document from waiting to processing . will it work and if yes is it the best solution … will there be any case it will result in deadlock or race condition? What other things I should consider while using findAndModify in this scenario.