[SERVER-15528] Distinct queries can scan many index keys without yielding read lock Created: 03/Oct/14  Updated: 11/Jul/16  Resolved: 15/Oct/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.0
Fix Version/s: 2.6.6, 2.7.8

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

Issue Links:
Related
related to SERVER-15152 When evaluating plans, some index can... Closed
Operating System: ALL
Backport Completed:
Participants:

 Description   

For certain distinct queries, the distinct scan query stage can scan many index keys between returning results. Distinct queries that generate inexact bounds and encounter non-matching index entries (and thus generate a call to skip() on the underlying index cursor) are affected. As a result, the distinct query can scan a large index range without yielding its read lock.

To reproduce, run the following shell snippet. The distinct query on the third line will scan the complete {a: 1, b: 1} index without yielding.

for (i=0; i<1000000; i++) { db.foo.insert({a: i, b: 1}); }
db.foo.ensureIndex({a: 1, b: 1});
db.foo.distinct("a", {a: {$ne: 0}, b: 0});

Regression introduced in 2.6.0.



 Comments   
Comment by Githook User [ 15/Oct/14 ]

Author:

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

Message: SERVER-15528 Refactor DistinctScan to do less in each work() call

(cherry picked from commit e0f47214d06738f14d0d0d731235a9f665a6b81f)
Branch: v2.6
https://github.com/mongodb/mongo/commit/638f6b7c9b02c30b53ac9e54a47466cb8dee194f

Comment by Githook User [ 15/Oct/14 ]

Author:

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

Message: SERVER-15528 Refactor DistinctScan to do less in each work() call
Branch: master
https://github.com/mongodb/mongo/commit/e0f47214d06738f14d0d0d731235a9f665a6b81f

Comment by J Rassi [ 03/Oct/14 ]

This ticket describes the same fundamental issue as SERVER-15152, except for the distinct scan stage instead of the index scan stage.

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