TTL Index is not working

248 views
Skip to first unread message

Sudhir Shekhsaria

unread,
Sep 2, 2015, 1:44:21 AM9/2/15
to mongodb-user
On Prodution  Server ,there is a  collection has TTL index on created_at field. But it is not working now and it was working fine till May. It has 3 hr TTL for document after that it will remove from collection automatically by mongo

Please suggest a appropriate solution ASAP as we are stuck in this issue.

Stephen Steneker

unread,
Sep 2, 2015, 11:11:04 PM9/2/15
to mongodb-user
On Wednesday, 2 September 2015 15:44:21 UTC+10, Sudhir Shekhsaria wrote:
On Prodution  Server ,there is a  collection has TTL index on created_at field. But it is not working now and it was working fine till May. It has 3 hr TTL for document after that it will remove from collection automatically by mongo

Hi Sudhir,

To help troubleshoot this can you please:

 - provide the index definition (i.e. from db.collection.getIndexes() )

 - provide examples of the created_at field values for documents that aren't removed?

 - confirm your exact version of MongoDB (i.e. via db.version() in the `mongo` shell)

TTL indexes only work if the indexed field in a document includes a BSON date. You could also check if some of your documents have field values that aren't dates by comparing the BSON type, eg:

db.collection.find({created_at: { $not: { $type: 9}}}).count();

Regards,
Stephen
Reply all
Reply to author
Forward
0 new messages