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

sort component of internal plan cache key syntax is ambiguous

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.0.0-rc7
    • Fix Version/s: 3.1.1
    • Component/s: Querying
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Quint Iteration 3.1.1

      Description

      The internal representation for the sort order of a plan cache key as defined in canonical_query.cpp:269-276 is ambiguous because it does not use any separators for multiple keys.

      These two queries produce the same cache key and could therefore incorrectly use a wrong cached plan:

      db.coll.find( {a: {$gt: 1}, b:1} ).sort( {a:1, b:1} )
      db.coll.find( {a: {$gt: 1}, b:1} ).sort( {aab:1} )
      

      Both produce the internal key: an[eqb,gta]~aaab.

      This could be avoided with a separator between multiple sort keys, e.g.

      an[eqb,gta]~aaab
      an[eqb,gta]~aa,ab
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: