- Notifications
You must be signed in to change notification settings - Fork925
chore: add files cache for reading template tar archives from db#17141
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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.
Overall LG!
Maybe we should add some metric on theentry
for when it was created. At some point some metrics like how long an entry exists would be useful.
We might even enforce some TTL or something 🤷
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
aslilac commentedApr 1, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
what would it look like if the entry got evicted while someone was holding it? the gc wouldn't actually free it, but then if someone requests it again we'd end up with a separate copy of everything because the cache would no longer see it. I kinda feel like an expiration time would only mask bugs. |
You are right. Can we add an issue to throw some prometheus metrics around this then? So if something does happen, we have somewhere to look. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
👍 LGTM, left a few nits
Some things to follow up:
- Add an issue for adding prometheus metrics to this cache
- Potentially revisit the API when we get to usage. If we can guarantee
Release
is called, that would be ideal 🙏
ac7ea08
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Closes#17052
Requirements
Multiple template versions can share a single "file"
fs.FS
interface pointers.Files should be "ref counted" so that they're released when no one is using them.
You should be able to fetch multiple different files in parallel, but you should not fetch the same file multiple times in parallel.
sync.Mutex
and alazy.ValueWithError
per file ID.Implementation
Uses afero for turning the tar data from the database into a readonly
io/fs.FS
Adds a
lazy.ValueWithError
as a counterpart tolazy.Value
, but with the ability to fail