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

feat(cache): Write temporary files in a dedicated directory #265

Merged
merged 12 commits into from
Oct 27, 2020

Conversation

flub
Copy link
Contributor

@flub flub commented Sep 4, 2020

This is not as clean as it should be because all locations do a lot of
path manipulation manually.

This is not as clean as it should be because all locations do a lot of
path manipulation manually.
@flub flub requested a review from a team September 4, 2020 07:43
src/actors/common/cache.rs Outdated Show resolved Hide resolved
src/cache.rs Outdated
@@ -323,26 +347,58 @@ pub struct Caches {

impl Caches {
pub fn from_config(config: &Config) -> io::Result<Self> {
let tmp_dir = config.cache_dir("tmp");
if let Some(ref tmp) = tmp_dir {
if tmp.exists() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the cleanup job starts, won't this get executed and the tmpdir wiped even though symbolicator is still working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, good catch!

/// actual location withing the `cache_dir`.
///
/// Just like for `cache_dir` when this cache is disabled this will be `None`.
tmp_dir: Option<PathBuf>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a situation where one wants to make this configurable? afaict it is not exposed as config param but I think we should avoid exposing it entirely.. I think NamedTempFile::new() is never what you want

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention was also not to expose this. You only get to chose a cache directory (or not) and we decide what to do inside of there. It makes me a little sad that you can create a Cache with cache_dir=Some(...) and tmp_dir=None or the other way around. But only code in this module should be able to do that.

Floris Bruynooghe added 3 commits September 4, 2020 11:15
Cleanup mode also creates the config and runs regularly during the
server process.  So we need to do the cleanup as part of server
startup explicitly.
@flub flub marked this pull request as draft September 4, 2020 09:17
@@ -403,6 +397,20 @@ impl Caches {
})
}

/// Clear the temporary files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make a case for emitting an error to Sentry if the tmpdir is not empty on restart

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only happen after a crash and there probably have been alerts for this already in that case? I fear this might just lead to duplicate reporting. It's not really a bad failure mode, just a backstop to some files never being cleaned up

Floris Bruynooghe added 4 commits October 15, 2020 16:58
The old code did this in the caller, perhaps that was a bit
questionable.  A lot of this is a bit questionable.
For some reaons I never got filenames and line numbers out of this, so
less useful than I was hoping.  I suspect I did something wrong though.
Floris Bruynooghe added 3 commits October 16, 2020 16:10
@flub flub marked this pull request as ready for review October 16, 2020 15:11
@flub flub changed the title Attempt to write temporary files in a dedicated directory feat(cache): Write temporary files in a dedicated directory Oct 16, 2020
@flub flub merged commit 5ad8293 into master Oct 27, 2020
@flub flub deleted the feat/cache-tmpdir branch October 27, 2020 08:52
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