[SERVER-80268] MongoDB TimeSeries Collection TTL Problem Created: 21/Aug/23  Updated: 08/Nov/23  Resolved: 08/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: zhijia zhang Assignee: Alison Rhea Thorne
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: HTML File attach1     Text File jira_file.txt     File populate_and_test.js    
Issue Links:
Duplicate
is duplicated by SERVER-80180 Time Series Collection Closed
Operating System: ALL
Steps To Reproduce:

you can see the attach1

Participants:

 Description   

Hi all,

   I met a strange problem about the time series collection, i create a time series collection with expireAfterSeconds but what i found is when the time is come the record was not delete the same as all of the doc in the bucket was expire. I will attach the file and you can test it .



 Comments   
Comment by Alison Rhea Thorne [ 08/Nov/23 ]

We haven’t heard back from you for some time, so I’m going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Comment by Alison Rhea Thorne [ 16/Oct/23 ]

We still need additional information to diagnose the problem. If this is still an issue for you, would you please confirm that the reproduction that we've provided matches the behavior that you are seeing? Thank you!

Comment by Alison Rhea Thorne [ 28/Sep/23 ]

Hello aaa15942975658@163.com,

I was able to replicate your reported behavior once making the adjustments that you noted. However, something I noticed is that within the data that you’ve provided, you have set the granularity for your Time Series collection to either minutes or hours depending on the dataset provided. Something that should be noted is that with a granularity of “hours” buckets can contain records with 30 days of separation. As such, can you clarify which granularity setting you have observed this behavior with? You can read more about these configurations here: Set up Automatic Removal for Time Series Collections (TTL)

For the time being, we continued replication attempts following your initial dataset set to “minutes”. Using a document generator filled with random timestamps between 2-3 days before the current timestamp, the given records are indeed removed as expected. However, when the generator is set to generate records just over or under 24 hours the reported behavior is observed.

We’ve attached an updated reproduction script to the ticket, can you confirm that the behavior that you’ve observed is replicated within said script? Once this is done, we can move forward with this ticket.

Thank you,
Rhea

Comment by zhijia zhang [ 14/Sep/23 ]

Hello, the reason why you did not find the problem when performing a replication is because it has been a long time.

you can use the attachment but change the timestamp as current timestamp。 

exp:

first create a timeseies collection use the follow command:

db.createCollection(
    "weather24h1",
    {
       timeseries:

{           timeField: "timestamp",           metaField: "metadata",           granularity: "hours"        }

,
       expireAfterSeconds: 86400
    }
)

second if the current date was ISODate("2023-08-21T14:11:35.930Z") you can make data was  ISODate("2023-08-20T11:00:00.000Z") and ISODate("2023-08-19T00:00:00.000Z") just like what i attach in the file 

 

third you will see the problem 

Comment by Alison Rhea Thorne [ 05/Sep/23 ]

Thank you for your report.

Based on what you've reported, it sounds like you are having issues with documents within a timeseries collection not being removed while on mongod version 5.0.18. We attempted to replicate this using the steps that you have provided, but have been unable to do so. In the versions tested (including the reported version 5.0.18) we have found that expired documents within a timeseries collection have been removed after 60 seconds as expected, if the configured timeframe has passed.

If you have not done so, we recommend setting up a fresh mongod instance elsewhere and attempting to replicate this issue. We've also gone ahead and provided a mongosh script ( populate_and_test.js ) to test whether or not documents are being deleted as expected.

One thing that we would like to note is that it's possible that the timeframe for expiry had not passed, or not enough time had been given for the database to remove the entries. 

In any case, we hope that this helps.

Comment by zhijia zhang [ 29/Aug/23 ]

my mongodb version was 5.0.18 community

Generated at Thu Feb 08 06:43:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.