MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Can cursors return the same document more than once in MongoDB 4.0?

Is it something we have to concern in version as of 4.0?

Read Isolation, Consistency, and Recency — MongoDB Manual

MongoDB cursors can return the same document more than once in some situations. As a cursor returns documents other operations may interleave with the query. If some of these operations change the indexed field on the index used by the query; then the cursor will return the same document more than once.

https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/#cursor-snapshot

The docs you are quoting are for the current version (4.2) so yes, there is no guarantee of a single point in time view when you iterate over a cursor unless you are in a transaction or otherwise force a stronger readConcern.

1 Like