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

Use the env TEMPDIR if available instead of P_tmpdir. #4921

Merged
merged 2 commits into from
Sep 30, 2021
Merged

Conversation

ironage
Copy link
Contributor

@ironage ironage commented Sep 30, 2021

On Mac this changes the directory that test files are written from "/var/tmp/" to "/var/folders/1y/_7..." which allows the OS to clean them up on a reboot.

Additionally, TestFile will clean up the temp directory it creates when finished, if not instructed to persist it.

This should mitigate part of https://jira.mongodb.org/browse/BUILD-13876 going forward.

My dev machine had 2 million mostly empty directories in /var/tmp/realm_* totalling 12 GB. Every run of the object-store tests created around 4000 directories there. Since at this scale, most attempts to do anything at that path from the terminal didn't work I had to use a script to clean it out:

            util::DirScanner dir("/var/tmp/");
            size_t count = 0;
            size_t did_delete = 0;
            std::string name;
            while (dir.next(name)) {
                if (name.size() > 6 && name.substr(0, 6) == "realm_") {
                    bool deleted = util::try_remove_dir_recursive("/var/tmp/" + name);
                    did_delete = did_delete + size_t(deleted);
                }
                ++count;
                if (count % 10000 == 0) {
                    std::cout << util::format("deleted %1 out of %2", did_delete, count) << std::endl;
                }
            }
            std::cout << "end of file listings" << std::endl;

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)

This does not affect Windows or Android.
On mac this changes the directory that test files are written from
"/var/tmp/" to "/var/folders/1y/_7..." which allows the OS to clean them
up on a reboot.

Additionally, `TestFile` will clean up the temp directory it creates
when finished, if not instructed to persist it.
@ironage ironage requested review from jbreams and jedelbo September 30, 2021 02:21
@ironage ironage self-assigned this Sep 30, 2021
@ironage ironage merged commit 7d65a82 into master Sep 30, 2021
@ironage ironage deleted the js/clean-os-dirs branch September 30, 2021 19:09
dianaafanador3 pushed a commit that referenced this pull request Oct 27, 2021
* Use the env TEMPDIR if available instead of P_tmpdir.

This does not affect Windows or Android.
On mac this changes the directory that test files are written from
"/var/tmp/" to "/var/folders/1y/_7..." which allows the OS to clean them
up on a reboot.

Additionally, `TestFile` will clean up the temp directory it creates
when finished, if not instructed to persist it.

* ignore exceptions when cleaning up
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants