Queries on a timeseries collection with a wildcard index can incorrectly uassert

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • ALL
    • Hide
      assert.commandWorked(db.createCollection(tsColl.getName(), {
          timeseries: {timeField: 't', metaField: 'm'},
      }));
      assert.commandWorked(tsColl.insert({t: new Date(), m: 1}));
      assert.commandWorked(tsColl.createIndex({  "m.$**" : 1 }))
      
      const query = [
          {
      	"$match" : {
                  "m" : {
                      "$eq" : 0			
                  }
              }
          },
          {
              "$sort" : {
                  "t" : 1
              }
          }
      ]
      
      tsColl.aggregate(query).toArray();
      // uassert: Consider using $getField or $setField for a field path with '.' or '$'. :: caused by :: FieldPath field names may not start with '$', given '$_path'.
      
      Show
      assert .commandWorked(db.createCollection(tsColl.getName(), { timeseries: {timeField: 't' , metaField: 'm' }, })); assert .commandWorked(tsColl.insert({t: new Date(), m: 1})); assert .commandWorked(tsColl.createIndex({ "m.$**" : 1 })) const query = [ { "$match" : { "m" : { "$eq" : 0 } } }, { "$sort" : { "t" : 1 } } ] tsColl.aggregate(query).toArray(); // uassert: Consider using $getField or $setField for a field path with '.' or '$' . :: caused by :: FieldPath field names may not start with '$' , given '$_path' .
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The repro provided shows that a wildcard index on the meta field in a TS collection can cause some queries to fail incorrectly. The queries that fail seem to eligible for the bounded sort optimization (printing the stacktrace also shows the bounded sorter rewrite in progress).

      If we do not create the wildcard index, the query completes successfully. Creating an index should not cause a valid query to fail.

              Assignee:
              Ruoxin Xu
              Reporter:
              Matt Boros
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: