简体   繁体   中英

MongoDB TTL index does not remove an expired record

I created a TTL index on my collection's created_at field to autoremove document after 30s but after sometime passed (5min later) the document didn't get removed. I read some related questions and I'm sure there was no typo in my collection. Here is the JSON after running db[collectionName].getIndexes()

[
{
    "v" : 2,
    "key" : {
        "_id" : 1
    },
    "name" : "_id_",
    "ns" : "record_db.collectionName"
},
{
    "v" : 2,
    "key" : {
        "created_at" : 1.0
    },
    "name" : "created_at_1",
    "ns" : "record_db.collectionName",
    "expireAfterSeconds" : 30.0
}

] And here is an example document:

{
  "_id" : ObjectId("5fc3823af29f9d9eb1518857"),
  "record_path" : path/to/file,
  "timestamp" : 1606648392,
  "humantime" : "29/11/2020 18:12:58",
  "created_at" : ISODate("2020-11-29T18:12:58.859Z")
}

ISODate("2020-11-29T18:12:58.859Z") not happened yet.

 const iso = "2020-11-29T18:12:58.859Z" const date = new Date(iso); console.log(date.toString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM