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

Distinct queries can scan many index keys without yielding read lock

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.6.6, 2.7.8
    • 2.6.0
    • Querying
    • None
    • ALL

    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

        Activity

          People

            rassi J Rassi
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: