Time-series allows meta field to be empty and indexing on empty field

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Execution
    • ALL
    • Hide
      const coll = db.coll;
      assert(coll.drop());
      
      // empty meta field
      assert.commandWorked(db.createCollection('coll', {timeseries: {timeField: 't', metaField: ''}}))
      
      assert.commandWorked(coll.insert({t: new Date(0), '': 1, a: 1}));
      assert.commandWorked(coll.createIndex({'': 1}));
      
      coll.find({$or: [{'': 1}, {a: 1}]}).toArray();
      // tassert: createPredicate() does not handle metadata predicates
      
      Show
      const coll = db.coll; assert (coll.drop()); // empty meta field assert .commandWorked(db.createCollection( 'coll' , {timeseries: {timeField: 't' , metaField: ''}})) assert .commandWorked(coll.insert({t: new Date(0), '': 1, a: 1})); assert .commandWorked(coll.createIndex({'': 1})); coll.find({$or: [{'': 1}, {a: 1}]}).toArray(); // tassert: createPredicate() does not handle metadata predicates
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The repro shows that if the meta field of a TS collection is an empty string, the user can create an index on the empty string. This can cause unexpected cases with query code, leading to a tassert as demonstrated.

      I'm not sure which issue is the root cause:

      • Empty field names allowed as the metafield
      • Empty field names allowed in the index
      • The query tassert may make the valid assumption that field names in indexes are nonempty

      My guess is the first one but it would be good to verify.

            Assignee:
            Unassigned
            Reporter:
            Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: