Question

Help me understand what level of consistency I can expect with MongoDB in this situation.

We are running a replica set with the consistency flag in Mongoid set to strong meaning that reads only go to the master. But the safe configuration is defaulted to false so write operations return immediately.

Assuming there aren't any errors, if a client app inserts a new large document and then quickly tries to read it in another thread, are we guaranteed to get the document back? Or do we need to turn safe mode on to ensure that level of consistency?

Was it helpful?

Solution

If you write and then subsequently read from a primary, you will not always get a consistent result. It matters whether you are on the same connection or not. If you are on the same connection, you do not need safe. If you are not on the same connection, you need safe.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top