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

fix: Don't persist cache files that error while writing #1579

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

loewenheim
Copy link
Contributor

This adds an early return in memory.rs so that if an InternalError is returned by a cache computation¹, we don't attempt to write the error and don't persist the temp file. This kills two birds with one stone:

  1. It fixes the "Internal errors should never be written out" issue we see in Sentry.
  2. More importantly, if a computation fails with an InternalError because of lack of disk space, we discard the resulting file immediately instead of preserving its (likely useless) contents.

Moreover, I also added some extra validation after symcache/ppdbcache/sourcemapcache conversion. Now, if somehow the write goes through but the file is invalid, we also return an InternalError and it will be deleted. This costs us nothing because parsing these files is essentially free. I thought about doing the same for cficache files, but there the tradeoff is less clear—parsing them takes significant resources, for a case we don't know ever occurs.

¹ Caused by an io::Error, for instance.

@loewenheim loewenheim self-assigned this Jan 8, 2025
@loewenheim loewenheim requested review from Swatinem and a team January 8, 2025 16:08
@loewenheim loewenheim merged commit 3998e5b into master Jan 9, 2025
13 checks passed
@loewenheim loewenheim deleted the fix/internal-errors branch January 9, 2025 09:07
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.

5 participants