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

cache gets verifies crc checksum on stored cache items #164

Merged
merged 5 commits into from
Feb 5, 2025

Conversation

assafvayner
Copy link
Contributor

FIX XET-142.

Previously we removed the chunk cache validation on the cache items on the get path since it turned out to be where all the time was spent on cache operations. This PR reintroduces checksum validation, now that we are using checksums rather than more expensive hashes.

Notably the verification is still rather expensive since it requires reading the entire file, whereas a simple cache get may only need to seek to 1 section of the file.

Verification is done only once on a best effort basis, i.e. it is not strictly enforced that the verification work is done only once, if 2 threads attempt to verify concurrently, double work is done. See VerificationCell.

@assafvayner assafvayner requested review from ylow and seanses February 4, 2025 00:49
@seanses
Copy link
Collaborator

seanses commented Feb 4, 2025

Why do we need to verify the cache content? Is there anything that may corrupt (or maliciously manipulate) the cache data on disk?

@assafvayner
Copy link
Contributor Author

Why do we need to verify the cache content? Is there anything that may corrupt (or maliciously manipulate) the cache data on disk?

This is to mitigate the risk of user error more than anything, i.e. the user or some program modified the cache files. I am personally of the opinion that we could rip out this validation, and instead drop it or replace with just a magic word check.

@assafvayner assafvayner merged commit f21b60c into main Feb 5, 2025
2 checks passed
@assafvayner assafvayner deleted the assaf/cache-verifies-crc branch February 5, 2025 21:17
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.

3 participants