Skip to content

Feature delete expired threads in mongo aio checkpointer #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

XenoAmess
Copy link

@XenoAmess XenoAmess commented Feb 18, 2025

add some utility to auto-delete expired threads in mongo aio checkpointer
that be useful when in real-world production usage

@XenoAmess XenoAmess force-pushed the feature-add-delete-expire branch from 2cb6e53 to 9241163 Compare February 18, 2025 07:53
@blink1073
Copy link
Collaborator

Hi @XenoAmess! Can you describe your use case for this feature? I'm not sure it is in scope for this library, is it something you could maintain separately?

@Pesokrava
Copy link

I would like to have this feature. The use case is pretty straightforward, after a while the DB will be populated with no longer relevant checkpointers. One option would be to have some sort of a cleanup CRON job but since mongo does support TTL, it would be much more convenient to have an option to use that built-in functionality. But for mongo TTL one needs a index on a timestamp / datetime field, which is currently not possible.

@XenoAmess
Copy link
Author

XenoAmess commented Mar 14, 2025

Hi @XenoAmess! Can you describe your use case for this feature?

we need this feature (at least in my work situation) to make sure the middleware cost would not be accumulate infinitally.

I'm not sure it is in scope for this library, is it something you could maintain separately?

Yes, currently we maintained a class in our repo for this thing, and that can work.

But I think maybe quite some people would need something like this.

If used in production usually we need to think about thinks like this IMO...

@XenoAmess
Copy link
Author

I would like to have this feature. The use case is pretty straightforward, after a while the DB will be populated with no longer relevant checkpointers. One option would be to have some sort of a cleanup CRON job but since mongo does support TTL, it would be much more convenient to have an option to use that built-in functionality. But for mongo TTL one needs a index on a timestamp / datetime field, which is currently not possible.

yes and notice that we need to delete a whole chat session when delete it, and we use a multiple document way to store it, it means if we use mongo TTL we might have possibility that a thread is half-deleted, that be dangerous

@jpfcabral
Copy link

Any updates on it?

@jpfcabral
Copy link

jpfcabral commented Mar 30, 2025

hey, @XenoAmess .

Let me know if could be easier if you just add a new index...

https://www.mongodb.com/docs/manual/core/index-ttl/

@XenoAmess
Copy link
Author

XenoAmess commented Mar 31, 2025

hey, @XenoAmess .

Let me know if could be easier if you just add a new index...

https://www.mongodb.com/docs/manual/core/index-ttl/

well if you implement it this way, you might take care about situation that parent node die before&after child node...

for example, ttl configuration change during an update, thus makes parent node ttl after child node

and please make sure a half-deleted session would not cause trouble, like, during this time of run of graph between 2 nodes, a very old message deleted due to ttl.

@caseyclements
Copy link
Collaborator

I prefer to proceed with #108 . TTL indexes are a great built-in feature of mongodb, and very low-touch. That said, I am currently implementing the BaseStore for long-term which deals explicitly with TTL.We'll learn a lot if I can get that that to work with TTL Indexes, and the LangGraph maintainers are happy with the solution.

@jpfcabral
Copy link

Good to hear, @caseyclements. Let me know if you need help with this. I'm currently using this implementation (#108) in my work and it will be very helpful to have these implementations thought out in the long run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants