-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.4.2
-
Component/s: None
-
None
-
Environment:Docker
-
ALL
-
I found problem on production server and try to prepare minimal example that can reproduce that situation. I try to obtain in generally the same .explain() description of winningPlan, that's a reason why it possible looks ugly or strength. It just example.
The example use popular pattern of pagination of search request. First request try get first 5 documents, second request try next 5 documents, third request try get first 10 documents (total documents in this example)
Looks for output:
Query skip 0, limit 5: { "_id" : ObjectId("5fc7a98ff658d92832ebeb98") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb99") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb96") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb95") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb97") } Query skip 5, limit 5: { "_id" : ObjectId("5fc7a98ff658d92832ebeb98") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb96") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb95") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb97") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb9b") } Query skip 0, limit 10: { "_id" : ObjectId("5fc7a98ff658d92832ebeb9d") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb9e") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb99") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb9c") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb9a") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb98") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb96") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb95") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb97") } { "_id" : ObjectId("5fc7a98ff658d92832ebeb9b") }
As we can see first and seconds results have intersections with ids:
5fc7a98ff658d92832ebeb98 5fc7a98ff658d92832ebeb96 5fc7a98ff658d92832ebeb95 5fc7a98ff658d92832ebeb97
and have no ids:
5fc7a98ff658d92832ebeb9d 5fc7a98ff658d92832ebeb9e 5fc7a98ff658d92832ebeb9c 5fc7a98ff658d92832ebeb9a
which have third result.
In practice this mean that i lost objects when try to paginate request of web app.
I can't reproduce this behavior in versions 4.2, 4.0, 3.6, only in 4.4.2.
Is it a bug of mongodb?
P.S. My suggestion is that a new stage "SORT_KEY_GENERATOR" change behavior. It is a general difference between .explain() of 4.2 and 4.4 versions
- duplicates
-
SERVER-51498 Sorting on duplicate values causes repeated results with limit and skip
- Closed