Mongorestore is not handling empty partialFilterExpression option correctly

XMLWordPrintableJSON

    • 3
    • Tools and Replicator
    • 0.25
    • Not Needed

      Problem Statement/Rationale

      type IndexDocument struct {
      	Options                 bson.M `bson:",inline"`
      	Key                     bson.D `bson:"key"`
      	PartialFilterExpression bson.D `bson:"partialFilterExpression,omitempty"`
      }
      

      The definition of IndexDocument is incorrect that if an index document has `partialFilterExpression` set to an empty document, the field would be omitted when marshaling it to BSON. For TTL indexes in time-series collections, this results in mongorestore failure to restore such indexes.

      Steps to Reproduce

      See SERVER-102799

      Expected Results

      Mongorestore should restore indexes with `partialFilterExpression` option correctly

      Actual Results

      Mongorestore failure:

      Failed: ttl_test_demo.sensor_data: error creating indexes for ttl_test_demo.sensor_data: createIndex error: (InvalidOptions) TTL indexes on time-series collections require a partialFilterExpression on the metaField
      

            Assignee:
            Jian Guan
            Reporter:
            Jian Guan
            Michael McClimon, Nick Weinberger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: