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

Distinct queries can scan many index keys without yielding read lock

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.6, 2.7.8
    • Affects Version/s: 2.6.0
    • Component/s: Querying
    • None
    • ALL

      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.

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

              Created:
              Updated:
              Resolved: