...
TTL index doesn't work.
thomas.schubert commented on Fri, 2 Dec 2016 00:10:39 +0000: Hi kreig, Thanks for letting us know – I'm glad you were able to identify the root cause of the issue. For MongoDB-related support discussion please feel free to post on the mongodb-users group or Stack Overflow with the mongodb tag. Kind regards, Thomas kreig commented on Fri, 2 Dec 2016 00:06:18 +0000: I found the problem. 2016-12-02T01:56:39.299+0200 I STORAGE [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset 2016-12-02T01:56:39.300+0200 I STORAGE [initandlisten] ** Restart with --replSet unless you are doing maintenance and no other clients are connected. 2016-12-02T01:56:39.300+0200 I STORAGE [initandlisten] ** The TTL collection monitor will not start because of this. 2016-12-02T01:56:39.300+0200 I STORAGE [initandlisten] ** 2016-12-02T01:56:39.300+0200 I STORAGE [initandlisten] For more info see http://dochub.mongodb.org/core/ttlcollections I was searching for [TTLMonitor] occurrences as it was recommended by @Dan and payed no attention to the warning. It was completely my fault, sorry... thomas.schubert commented on Wed, 30 Nov 2016 19:38:24 +0000: Hi kreig, Would you please attach the complete log at log verbosity 1, so we can investigate? Additionally, would you please execute the same steps on MongoDB 3.2.11, and provide the complete logs at verbosity 1 so we can determine whether this is a regression? Thank you, Thomas kreig commented on Wed, 30 Nov 2016 18:07:16 +0000: There are no records from [TTLMonitor] in the log. It looks like TTLMonitor thread never starts. I have restarted database several times. And also tried to disable and re-enable TTLMonitor using db.adminCommand({setParameter:1, ttlMonitorEnabled:true}); Nothing works. Maybe there are some additional settings? mark.benvenuto commented on Wed, 30 Nov 2016 15:58:33 +0000: I was not able to repro with the steps you provided above. It may be difficult to see in the log where the TTLMonitor is started since it is not immediately started with other threads. Here is an example of log output that has been trimmed to show some relevant log lines from "./mongod.exe --storageEngine=mmapv1 -v" ... 2016-11-30T10:22:55.898-0500 D COMMAND [TTLMonitor] BackgroundJob starting: TTLMonitor ... 2016-11-30T10:22:56.081-0500 D COMMAND [ClientCursorMonitor] BackgroundJob starting: ClientCursorMonitor 2016-11-30T10:22:56.081-0500 D COMMAND [PeriodicTaskRunner] BackgroundJob starting: PeriodicTaskRunner ... 2016-11-30T10:23:55.559-0500 I STORAGE [DataFileSync] flushing mmaps took 125ms for 6 files 2016-11-30T10:23:55.902-0500 D INDEX [TTLMonitor] ns: test.logTest key: { Created: 1.0 } name: Created_1 2016-11-30T10:23:55.905-0500 D INDEX [TTLMonitor] deleted: 0 kreig commented on Wed, 30 Nov 2016 09:26:21 +0000: TTLMonitor thread doesn't run at all. Here is my log output: 2016-11-30T11:14:30.367+0200 I STORAGE [DataFileSync] flushing mmaps took 66ms for 52 files 2016-11-30T11:15:30.346+0200 I STORAGE [DataFileSync] flushing mmaps took 43ms for 52 files 2016-11-30T11:16:30.367+0200 I STORAGE [DataFileSync] flushing mmaps took 64ms for 52 files 2016-11-30T11:17:30.340+0200 I STORAGE [DataFileSync] flushing mmaps took 37ms for 52 files I can see ClientCursorMonitor and PeriodicTaskRunner startup, but TTLMonitor never starts. 2016-11-30T11:12:30.687+0200 D COMMAND [ClientCursorMonitor] BackgroundJob starting: ClientCursorMonitor 2016-11-30T11:12:30.687+0200 D COMMAND [PeriodicTaskRunner] BackgroundJob starting: PeriodicTaskRunner I'm running `mongod` with default configuration options. Some more diagnostic info: > db.adminCommand({getParameter:1, ttlMonitorEnabled:1}); { "ttlMonitorEnabled" : true, "ok" : 1 } > db.adminCommand({getParameter:1, ttlMonitorSleepSecs: 1}); { "ttlMonitorSleepSecs" : 60, "ok" : 1 } dan@10gen.com commented on Wed, 30 Nov 2016 03:59:12 +0000: If you run mongod with verbose level set to 1, you can see the TTL monitor running. It only runs once a minute, so you may have to wait up to 119 seconds for the monitor to detect and delete the record from your example. To do so, execute mongod -v. Look for a message in the logs like the following to indicate it is running: 2016-11-29T22:53:34.552-0500 D INDEX [TTLMonitor] ns: test.logTest key: { Created: 1.0 } name: Created_1 2016-11-29T22:53:34.552-0500 D INDEX [TTLMonitor] deleted: 1 And you can see that the monitor started normally (earlier in the logs) by finding this message in the logs: 2016-11-29T22:51:34.545-0500 D COMMAND [TTLMonitor] BackgroundJob starting: TTLMonitor
db.logTest.insertOne({_id:new ObjectId(), Created: new Date()}); db.logTest.createIndex( { "Created": 1 }, { expireAfterSeconds: 60 });