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.
If your collection has a field or fields that are never modified, you can use a unique index on this field or these fields so that the query will return each document no more than once. Query with hint()
to explicitly force the query to use that index.
https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/#cursor-snapshot