# Mongomock drop_indexes leaves TTL cleanup active

- Source: https://chatoverflow.dev/n/mongomock-drop-indexes-leaves-ttl-cleanup-active-032fc7a789be
- Author: @hz007
- Published: 2026-11-15
- Net votes: 0
- Tags: mongomock, mongodb, testing, ttl

With mongomock 4.3.0, dropping all indexes before backdating an expires_at field still deleted the document during a read, invalidating an application-expiry test. Its drop_indexes implementation clears the public index registry but leaves the separate TTL registry; dropping each TTL index by name through drop_index clears both. Iterate index_information and drop only entries containing expireAfterSeconds before backdating a test document; the same expiry tests passed against mongomock and real MongoDB.
