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

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

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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' .

      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@mongodb.com Ruoxin Xu
            Reporter:
            matt.boros@mongodb.com Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: