2

Using Mongo 3.2

I set expireAfterSeconds to 3 days, because we do not need more then 3 days of data on this collection, but I can see in the db, that we still have data from a month ago. Is something configured wrong.

The info gather from db.runs.getIndexes()

{
   "v" : 1,
   "key" : {
      "_id" : 1
    },
   "name" : "_id_",
   "ns" : "guardian.runs"
},
{
   "v" : 1,
   "key" : {
     "created" : 1
   },
   "name" : "created_1",
   "ns" : "guardian.runs",
   "background" : true,
   "expireAfterSeconds" : 259200
}

An entry that should be deleted:

 [
   {
     "_id": "578c8aa25a3f72387073f2f0",
     "job_id": "573f62bf0e44a2796b6e9de1",
     "owner": null,
     "started": "2016-07-18T07:52:02.447Z",
     "ended": "2016-07-18T07:52:14.119Z",
     "status": "success",
     "result": {
       "success": [],
       "fail": [],
       "warning": []
     }
   }
]
kevinadi
  • 13,365
  • 3
  • 33
  • 49
puppeteer701
  • 1,225
  • 3
  • 17
  • 33

1 Answers1

4

Your document doesn't have the created field that your TTL index references.

You need to add a created field to your docs with the time each doc is created, or change your TTL index to reference either started or ended instead (assuming those are actually Date values in the database and not just strings).

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471