-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
fix(caching): Eagerly cleanup old versions #1582
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there is an old cache file version which is not part of the fallbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
The same thing that currently happens, it would eventually be cleaned up by the |
@jjbayer @Swatinem @Dav1dde I moved the deletion of old files into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
It was definitely a good catch; for incompatible cache version bumps the original version of this change would've made no difference. |
I believe we intentionally did not clean these up, just in case one wants to revert a deploy. |
Since the refresh process is gradual & throttled, what's the worst case behavior after a revert? The old files would still be in the shared cache, right? |
Ah. Hm. That's also a fair point. It applies equally regardless of whether we're doing a compatible or incompatible bump, though. This seems like a genuine dilemma to me—do we want to keep old caches around for rollbacks or delete theme eagerly to limit storage consumption during updates? |
The upgrade case is gonna happen more often than the rollback case, in a normal update we already have to deal with missing caches, so that's no different from (down-)grading imo. |
A middle ground could be to give the old files a shorter TTL, e.g. 1 hour. To me running out of disk space seems like a worse failure mode than having a cold(er) cache on rollback, but I'm biased. |
Currently, when we recompute a cache entry for which a fallback version exists, we just add the new version and leave the fallback in place. The idea was that the fallback version would fall out of use and eventually be cleaned up by the cleanup task.
While this is true, "eventually" is doing a lot of work here. In the immediate term, it's massively wasteful. Therefore, we now delete the fallback versions in
spawn_refresh
immediately after the new cache entry has been computed.Fixes #1577.
ETA: Changed this to always deleting old versions on compute, not just on lazy recomputes. That way it also covers incompatible cache version bumps.