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

cargo test eventually fills up /tmp and fails #4779

Open
jbencin opened this issue May 10, 2024 · 9 comments
Open

cargo test eventually fills up /tmp and fails #4779

jbencin opened this issue May 10, 2024 · 9 comments
Assignees

Comments

@jbencin
Copy link
Contributor

jbencin commented May 10, 2024

Describe the bug
If you run cargo test repeatedly, /tmp fills up and you start getting errors like this:

thread 'util_lib::bloom::test::test_bloom_counter_is_invertible' panicked at stackslib/src/util_lib/bloom.rs:735:21:
called `Result::unwrap()` on an `Err` value: SqliteFailure(Error { code: DiskFull, extended_code: 13 }, Some("database or disk is full"))

Steps To Reproduce
Run cargo test or cargo nextest run repeatedly

Expected behavior
Tests should clean up after themselves, or re-use data from previous tests

Environment (please complete the following information):

  • OS: Manjaro Linux
  • Rust version: 1.78
  • Version: 4afa9ef71
@wileyj
Copy link
Contributor

wileyj commented May 13, 2024

do you have a partition for /tmp of a specific size?

@jbencin
Copy link
Contributor Author

jbencin commented May 13, 2024

My /tmp directory is a 16GB tmpfs filesystem, which lives in RAM/swap. That's the default setup for Arch Linux, and probably other distros as well

Even if it doesn't run out of space, it's still consuming a lot of RAM unnecessarily. I have 32GB here, and old files from cargo test can eat up half that

I know most of our devs use MacBooks, and I have no idea how OS X handles this and if it's a problem for them

@jcnelson
Copy link
Member

FWIW, neither Debian nor Alpine use a RAM filesystem for /tmp. They use tmpfs, or nothing at all (it's just part of root).

@jbencin
Copy link
Contributor Author

jbencin commented May 13, 2024

tmpfs is not ramdisk but uses "virtual memory", which means data can be in either RAM or swap space. See tmpfs kernel docs here. So any distro that mounts tmpfs on /tmp is going to run into problems unless it is rebooted frequently

Am I the only one having an issue with this?

@jcnelson
Copy link
Member

jcnelson commented May 13, 2024

tmpfs is not ramdisk but uses "virtual memory", which means data can be in either RAM or swap space.

Right; you could conceivably deal with this problem by increasing your swap space. These distros' /tmp is backed not exclusively by RAM, but by a (user-chosen) amount of disk.

Am I the only one having an issue with this?

Maybe? My /tmp on my Linux boxen are all simply directories.

$ mount | grep 'on /tmp' | wc -l
0

The oldest file in this computer's /tmp is from August 19, 2021.

@jbencin
Copy link
Contributor Author

jbencin commented May 13, 2024

Maybe? My /tmp on my Linux boxen are all simply directories.

You're using Debian, right? Debian by default doesn't use tmpfs. Arch does. Not sure about other popular distros like Ubuntu, Fedora, etc.

Even if others aren't getting to the point where they are seeing actual test failures, I still think we should do something about it, because taking up extra RAM or disk space is never a good thing

Proposed Solutions

Used Fixed Names

Instead of using random file/directory names for each invocation of cargo test, use fixed names or psuedo-random names generated from a fixed seed. If data already exists from a previous test, remove it first

Implement Drop trait

Implement a simple wrapper around std::fs::File and implement Drop for it, so that the files are removed when the variable which owns them goes out of scope. Maybe not the right solution if we need to examine files after a failed test

@jcnelson
Copy link
Member

Even if others aren't getting to the point where they are seeing actual test failures, I still think we should do something about it, because taking up extra RAM or disk space is never a good thing

We deliberately keep things on disk so we can inspect them on failed test runs, so that's probably not going to change. The value it provides for debugging is immense.

Why can't you just alter your /etc/fstab to not mount /tmp as tmpfs?

@jbencin
Copy link
Contributor Author

jbencin commented May 13, 2024

We deliberately keep things on disk so we can inspect them on failed test runs, so that's probably not going to change. The value it provides for debugging is immense.

I understand this. Is it useful to keep all of the data indefinitely, of can we only keep data from the most recent cargo test run?

@wileyj
Copy link
Contributor

wileyj commented May 14, 2024 via email

@saralab saralab assigned wileyj, kantai and jbencin and unassigned kantai and wileyj May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: 🆕 New
Development

No branches or pull requests

4 participants