Skip to content
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

Provide mechanism or documentation for cache cleanup #13732

Closed
bizrad opened this issue Jan 21, 2022 · 13 comments · Fixed by #20061
Closed

Provide mechanism or documentation for cache cleanup #13732

bizrad opened this issue Jan 21, 2022 · 13 comments · Fixed by #20061
Assignees
Labels
core:cache help wanted Help is needed or welcomed on this issue priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:feature Feature (new functionality)

Comments

@bizrad
Copy link

bizrad commented Jan 21, 2022

What would you like Renovate to be able to do?

It would be nice to offer a method of pruning the cache. On a run with and empty cache directory it populates 32M of space in our instance and after 6 months of hourly runs this grows to 88G.

This is also an issue when using GitLab cache which zips -> uploads and downloads -> unzips the cache on each run, so over time runs begin to take longer and longer.

The current workaround it to completely wipe the cache on a regular basis or when a disk fills up.

Alternatively, if this is not implemented as a feature in code then documentation should be updated provide information on how cache can be pruned by running other commands like find /renovate/cache -type f -mtime +30 -delete or if this is not possible and the whole cache should be wiped regularly.

If you have any ideas on how this should be implemented, please tell us here.

I think it would be preferable to have a config option that can enable cache cleanup (true/false).
A second option to tune age of cache items may also be desirable (e.g. 30d)

Is this a feature you are interested in implementing yourself?

No

@bizrad bizrad added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality) labels Jan 21, 2022
@viceice
Copy link
Member

viceice commented Jan 21, 2022

I think we can manage some cleanup in cache teardown, which is called anyways.

Redis a s doing this automatically, so i think we can do something similar in renovate file / cacache.

@viceice
Copy link
Member

viceice commented Jan 21, 2022

Maybe simply run verify at end?

https://github.com/npm/cacache#verify

@rarkins
Copy link
Collaborator

rarkins commented Jan 21, 2022

Sounds like verify would clean up some cacache internals, but I don't think it would help us clean up our own expired cache entries.

@rarkins
Copy link
Collaborator

rarkins commented Jan 21, 2022

I think what's needed is to run ls to get every entry, then delete it if it's expired. We may need to try their streaming approach to not run out of memory when it's large. This should be done at the very end of a run

@buffcode
Copy link

Maybe Symfony's logic can be reused here:

  • prune() scans the local cache directory using a generator 1
  • all cache files have the expiry time in the first line 2 3, so not the whole cache file has to be retrieved / parsed

Footnotes

  1. https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Cache/Traits/FilesystemTrait.php#L34

  2. https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Cache/Traits/FilesystemTrait.php#L98

  3. https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Cache/Traits/FilesystemTrait.php#L39

@viceice
Copy link
Member

viceice commented Jan 25, 2022

I think the ls.stream function is the way to go.

@stropho

This comment was marked as off-topic.

@rarkins

This comment was marked as resolved.

@rarkins rarkins added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others core:cache status:ready and removed priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started labels Nov 25, 2022
@b-a-t
Copy link

b-a-t commented Dec 18, 2022

Is there any development happening on this feature request? We are forced to periodically stop the RenovateBot(-on-premise) and completely wipe out the cache, as it grows uncontrollably and takes all the given disk space(OK, we allocated it a separate LV, so it won't bring the whole machine down).

@rarkins
Copy link
Collaborator

rarkins commented Dec 19, 2022

No development planned any time soon, but community PRs would be welcome.

What I suggest:

  • Add a new global option cleanCache which defaults to never but has options first, and last
  • If option is first or last (i.e. at beginning or end) then use the streaming ls command to fetch all values and delete them if expired

@rarkins rarkins added the help wanted Help is needed or welcomed on this issue label Dec 19, 2022
@mrsimo
Copy link

mrsimo commented Jan 26, 2023

Just wanted to mention that since recent changes we've started noticing a growth in cache use:

image

Went from almost stable use to linear growth. That started when we upgraded from 34.77.1 to 34.94.0 (we do weekly upgrades). The changes that stood out to me were #19623 and #19059, but I've no idea. All the growth is in cache/renovate/renovate-cache-v1/content-v2/sha512.

We'll look into clearing the cache manually somehow, but wanted to leave this message to bring up that recent changes might make this problem worse sooner for folks.

@viceice
Copy link
Member

viceice commented Jan 26, 2023

I'm using redis cache for that reason 😉

rarkins added a commit that referenced this issue Jan 27, 2023
@rarkins rarkins self-assigned this Jan 27, 2023
@rarkins rarkins added status:in-progress Someone is working on implementation and removed status:ready labels Jan 27, 2023
rarkins added a commit that referenced this issue Feb 1, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 4, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 10, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 17, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 20, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 23, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 25, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Feb 27, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Mar 4, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Mar 8, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Mar 10, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Mar 10, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
rarkins added a commit that referenced this issue Mar 10, 2023
Checks file cache for expired items at the end of a run. Non-breaking change but it may result in some long cleanup jobs for any bots which have been left to populate their package cache for a long time.

Closes #13732
@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 35.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core:cache help wanted Help is needed or welcomed on this issue priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants