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

Command error on specific combination of compound index

    • Fully Compatible
    • ALL
    • QE 2022-08-08

      I have a collection with an index declared as: ({siteId: 1, startDate:1, endDate: 1}, {collation: {"locale": "en"}}).

      Some aggregate queries generate database errors, such as:

       

      {
        "aggregate" : "MyColl",
        "pipeline" : [{
            "$match" : {
              "siteId": {
                "$oid": "5bfeb296db127e1168efbf13"
              },
              "$or" : [{
                  "startDate" : null
                }, {
                  "startDate" : {
                    "$gte" : "2022-01-01"
                  }
                }]
            }
          }, {
            "$sort" : {
              "startDate" : 1,
              "endDate" : 1
            }
          }],
        "collation" : {
          "locale" : "en"
        }
      }

      The database responds:

       

      {
        "ok" : 0.0,
        "errmsg" : "assertion src/mongo/bson/bsonobjbuilder.h:195",
        "code" : 8,
        "codeName" : "UnknownError"
      }

      It only occurs when there are matches where the startDate field is null (undefined).

        1. CompassError.png
          85 kB
          Manuel Cabral
        2. DataExample.json
          2 kB
          Manuel Cabral
        3. mongoLogs.txt
          37 kB
          Manuel Cabral

            Assignee:
            denis.grebennicov@mongodb.com Denis Grebennicov
            Reporter:
            manuel.cabral@vooban.com Manuel Cabral
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: