Normally this works fine, but every once in a while at the end of the
returned list, one or more documents will be seen a second time. So we get
duplicates. When this happens they are always at the end and appear to be
sorted amongst themselves, but not as a whole.
So the “sorted list” with extra documents would be: A, B, C, D, E, F, G, H,
I, C, E
I searched around and it looks like this might be being caused because we
have other threads that are updating the records in the docs collection at
the same time.
We are currently using Mongo 2.6.10. If you think this might have been
resolved in a newer version we will look into the upgrade. I didn’t see
anything in the release notes.
There have been a significant number of changes since 2.6.10, so I would
definitely recommend testing the upgrade to a newer release series of
MongoDB (i.e. latest 3.0.x or 3.2.x) to see if this issue still occurs.