Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-15528

Distinct queries can scan many index keys without yielding read lock

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: 2.6.6, 2.7.8
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL
    • Backport Completed:

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: