Skip to content

Target directories are not purged after build failures #820

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

Closed
pietroalbini opened this issue Jun 6, 2020 · 8 comments · Fixed by #2250
Closed

Target directories are not purged after build failures #820

pietroalbini opened this issue Jun 6, 2020 · 8 comments · Fixed by #2250
Labels
A-builds Area: Building the documentation for a crate C-bug Category: This is a bug E-medium Effort: This requires a fair amount of work P-medium Medium priority

Comments

@pietroalbini
Copy link
Member

While there is code to purge target directories once a build finishes, if an error happens during the build that code is never executed, leaking disk space. We should make sure the target directory is always purged, otherwise we risk running out of disk space if a lot of crates fail to build (for example during today's outage).

@jyn514 jyn514 self-assigned this Jun 6, 2020
@jyn514
Copy link
Member

jyn514 commented Jun 6, 2020

@pietroalbini I think this would be best addressed by making BuildDirectory having a drop impl that calls purge(). I can make a PR to that effect.

@pietroalbini
Copy link
Member Author

That shouldn't be the default behavior, but I'd welcome a BuildDirectory::purge_on_drop(bool).

@jyn514
Copy link
Member

jyn514 commented Jun 8, 2020

As an alternative to the drop impl, we decided it would be more reliable to have a shared cleanup: AtomicBool. When the directory is created, cleanup is set to true to indicate there are resources that are being used. When the build finishes, the directory will be deleted and cleanup will be set to false. Whenever the daemon starts a new build, it will check cleanup, and if set to true, delete all build directories.

Rustwide will need a new .clean_build_directories() API to go with clean_caches().

@jyn514
Copy link
Member

jyn514 commented Jun 8, 2020

The advantage of this method is it works even if the thread is killed and does not run destructors.

@pietroalbini
Copy link
Member Author

Hmm, wait, that's not what I was proposing during the triage meeting.

The builder thread currently starts each loop by checking if a crate is available to build, and if one is present it builds that crate. My suggestion is to add a check in every iteration of the loop that purges all the build directories and, if the disk usage is over a threshold, purges all the caches.

@jyn514
Copy link
Member

jyn514 commented Jun 9, 2020

Thanks for the correction, I keep calling it the wrong thing. What I mean is this bit of code:

match doc_builder.get_new_crates() {

@jyn514 jyn514 added A-builds Area: Building the documentation for a crate C-bug Category: This is a bug P-medium Medium priority E-medium Effort: This requires a fair amount of work labels Jul 13, 2020
@jyn514 jyn514 removed their assignment Feb 15, 2022
@syphar
Copy link
Member

syphar commented Aug 3, 2023

@Nemo157 what's your thought on this?

Currently we are not purging all build dirs on each iteration.

( we are purging all caches on toolchain change )

@syphar
Copy link
Member

syphar commented Aug 3, 2023

and while normal build failures would also lead to the release target directory being purged after the build,

there are some error situations where we use ?, where we wouldn't do this (apart from normal panics)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builds Area: Building the documentation for a crate C-bug Category: This is a bug E-medium Effort: This requires a fair amount of work P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants