What’s up everyone.
I recently encountered an issue where in a MongoDB service, all TTL indexes for collections are not effective。
It is determined through the following method:
db.serverStatus().metrics.ttl
{
"deletedDocuments" : NumberLong(1487129845),
"passes" : NumberLong(505811)
}
The 'deletedDocuments' field and 'passes' field has not changed in the past two days
I did some tests. In two identical versions of MongoDB services, the same database and collections were created, the same data was inserted, and the same indexes were created. The problematic service and expired data were not cleaned up, but the normal service and expired data were cleaned up normally. Refer to the following diagram for testing steps
Through service monitoring, I found that the db.serverStatus().metrics.ttl.passes field of the primary node in this cluster has not changed, but there has been a change in the db.serverStatus().metrics.ttl.passes field of the secondary node.
Therefore, I performed a master-slave switch on the cluster.
Within about ten minutes after the switch, the TTL index took effect, but after ten minutes, the db.serverStatus().metrics.ttl.passes of the new master did not change either, and the passes field of the secondary node changed. After testing again, the TTL index on the new master did not take effect again.
It seems like the primary node in the cluster ,TTL Monitor Thread had some problem