[SERVER-15287] Query planner sort analysis incorrectly allows index key pattern plugin fields to provide sort Created: 17/Sep/14  Updated: 11/Jul/16  Resolved: 22/Sep/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.4
Fix Version/s: 2.6.5, 2.7.7

Type: Bug Priority: Major - P3
Reporter: Konstantin Kardamanov Assignee: J Rassi
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-11568 query optimizer fails to use index wh... Closed
Operating System: ALL
Backport Completed:
Steps To Reproduce:

use test;
 
db.sorthashed.insert([
    {str:'bravo'},
    {str:'alpha'},
    {str:'tango'},
    {str:'charlie'}
]); // intentionally inserted out of alpha order, field in question is `str`
db.sorthashed.find({}).sort({str:1}).pretty(); // shows in order
 
db.sorthashed.ensureIndex({str:'hashed'},{background:false});
db.sorthashed.find({}).sort({str:1}).pretty(); // shows in order
 
db.sorthashed.find({str: {$in: ['bravo', 'alpha', 'tango', 'charlie']}}).sort({str:1}) // shows out of order

Participants:
Linked BF Score: 0

 Description   

It seems when query planner uses hashed index for search, the same hashed index will be used for sorting. The use-case is a light modification of use-case listed in SERVER-13899

Reproduced on mongod-2.6.4



 Comments   
Comment by Githook User [ 22/Sep/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-15287 LiteParsedQuery should take ownership of request params

(cherry picked from commit 2ca7cef6b39d1ffc0c8b54ca6e12bb9d8c633060)
Branch: v2.6
https://github.com/mongodb/mongo/commit/a093502b6c97731a964aff8b499ec0378c3c53e5

Comment by Githook User [ 22/Sep/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-15287 LiteParsedQuery should take ownership of request params
Branch: master
https://github.com/mongodb/mongo/commit/ed9896eb2b9fc49e005019fbb0dbc411851b1d40

Comment by Githook User [ 22/Sep/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-15287 Can't use index key pattern plugin fields to provide sort

(cherry picked from commit ad1dafb013342faae7e998586a0c35b70ba75636)
Branch: v2.6
https://github.com/mongodb/mongo/commit/16c35896492c55c129b07caa38c695301e77ade6

Comment by Githook User [ 22/Sep/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-15287 Can't use index key pattern plugin fields to provide sort
Branch: master
https://github.com/mongodb/mongo/commit/ad1dafb013342faae7e998586a0c35b70ba75636

Comment by J Rassi [ 17/Sep/14 ]

korum, thanks for reporting this issue. I'm able to confirm it as a regression introduced in version 2.6.0 of the server. Please continue to watch this ticket for updates on when a fix will be available, and for updates on any workaround solutions.

Assigning to hari.khalsa@10gen.com for triage.

Generated at Thu Feb 08 03:37:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.