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

createIndexes should confirm that index options are valid in respect to the underlying collection

    • Fully Compatible
    • ALL
    • Hide
      > db.createCollection("test", {capped:true, size: 102400})
      { "ok" : 1 }
      > db.test.ensureIndex({foo:1}, {expireAfterSeconds: 10})
      {
              "createdCollectionAutomatically" : false,
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "ok" : 1
      }
      > db.test.insert({foo:new Date()})
      WriteResult({ "nInserted" : 1 })
      
      2016-01-19T18:17:11.210+1100 I STORAGE  [TTLMonitor] failing remove on a capped ns test.test
      2016-01-19T18:17:11.210+1100 E INDEX    [TTLMonitor] Error processing ttl index: { v: 1, key: { foo: 1.0 }, name: "foo_1", ns: "test.test", expireAfterSeconds: 10.0 } -- 10089 cannot remove from a capped collection
      
      Show
      > db.createCollection("test", {capped:true, size: 102400}) { "ok" : 1 } > db.test.ensureIndex({foo:1}, {expireAfterSeconds: 10}) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.test.insert({foo:new Date()}) WriteResult({ "nInserted" : 1 }) 2016-01-19T18:17:11.210+1100 I STORAGE [TTLMonitor] failing remove on a capped ns test.test 2016-01-19T18:17:11.210+1100 E INDEX [TTLMonitor] Error processing ttl index: { v: 1, key: { foo: 1.0 }, name: "foo_1", ns: "test.test", expireAfterSeconds: 10.0 } -- 10089 cannot remove from a capped collection
    • Execution Team 2021-11-01, Execution Team 2021-11-15, Execution Team 2021-11-29

      As reported in SERVER-769, it is possible to create a TTL index on a capped collection. This results in failed TTL document deletion once expiration is hit.

      We should audit which index options are invalid for specific collection options and add validation so that createIndexes will fail if specified.

            Assignee:
            gabriel.marks@mongodb.com Gabriel Marks
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: