[Feature] Cleanup old agenda documents in Mongo
jdorn opened this issue · comments
Description of Feature
The eventCreated
agenda job inserts a new document in Mongo for every event that happens in GrowthBook. Eventually, this can cause the agenda jobs collection to have a huge number of documents and cause queries to time out or fail.
We should add a cronjob to periodically clean up these old documents that aren't needed anymore. Specifically, we should delete any docs with nextRunAt
set to null
that were last run more than 24 hours ago to give plenty of buffer for failure retries.
Sort of in the same vein (but happy to open a separate issue for it): I think the queries
collection was also a culprit here for us, it had gotten pretty large and I think the checks for reusing queries do a find
based on the full query string. Cleaning those up probably isn't as easy (because experimentsnapshots
reference them), but maybe hashing the query and checking that would speed those up?