Behavior
Timing of Delete Operations
MongoDB doesn't guarantee that expired data will be deleted immediately
upon expiration. Once all documents in a bucket are expired, the
background task that removes expired buckets removes the bucket during
the next run. The maximum span of time that a single bucket is allowed
to cover is controlled by the granularity of the time series
collection:
granularity | Covered Time Span |
|---|---|
| one hour |
| 24 hours |
| 30 days |
The background task that removes expired buckets runs every 60 seconds. Therefore, documents may remain in a collection during the period between the expiration of the document, the expiration of all other documents in the bucket and the running of the background task.
Because the duration of the removal operation depends on the workload of your mongod instance, expired data may exist for some time beyond the 60 second period between runs of the background task.