Is there any way to disable TTL deletion thread in mongoDB?

I know that you can modify the ttl index expireAfterSeconds value to a high number in order to "technically" stop ttl from deleting, but i am interesting in disabling the ttl thread completely for some time and enable it later.

Thanks in advance


You can use the admin command:

db.adminCommand({setParameter:1, ttlMonitorEnabled:false});

To re-enable, use the same command with true.

  • Thanks, it introduced on 2.4.6 , i was looking an older manual :) – Antonios Dec 5 '14 at 10:58
  • @AsyaKamsky: Does this work in a sharded environment? – Markus W Mahlberg Dec 18 '14 at 21:06
  • it works on any mongod whether it's a shard or standalone or replica node. not on mongos though as mongos doesn't run the TTL thread. – Asya Kamsky Dec 23 '14 at 3:29
  • By the way, be aware that if the TTL thread has already woken up and identified documents to be deleted, changing this value appears to have no effect, at least on v2.6.10. :( – Matt Passell Dec 16 '15 at 21:35
  • that's like saying if the delete already happened changing the value has no effect - I'm guessing by the time you try change the value, the documents are already deleted. – Asya Kamsky Dec 17 '15 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.