I was looking for a solution to findOneAndUpdate a random document and I've found this:
Find One and Update with random document?
I had already thinked in that solution from accepted answer but I thought this could result in a race condition. Is that possible? I thought if two people call the same function at the same time, there is a chance of both get the same random document and one update will be overwritten with the other one. If race condition is possible in this case what can I do to find a random document and update in proper way? I have to set a pessimistic lock?