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

Prevent fd leak in random slasher tests #6254

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

michaelsproul
Copy link
Member

@michaelsproul michaelsproul commented Aug 13, 2024

Issue Addressed

Presently the random slasher tests crash after a few thousand iterations with an error about file descriptor exhaustion. The reason for this is that we use Box::leak to give the slasher database a 'static lifetime. As a result, if more than 1 SlasherDB is ever created, its destructor will not run and the open files will never be closed. Even though the tempdir will delete the DB directory containing the files, this does not free the

Proposed Changes

Reuse the same database for each test rather than creating a new one. The contents of the database are deleted completely between iterations. Some refactoring to allow changing the config between iterations was required.

Additional Info

You can reproduce the crash after a few minutes running this command on unstable:

cargo test -p slasher --release --test random -- --ignored no_crash --nocapture

After this PR, it can run indefinitely.

@michaelsproul michaelsproul added test improvement Improve tests slasher ready-for-review The code is ready for review labels Aug 13, 2024
@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Aug 19, 2024
@michaelsproul
Copy link
Member Author

@mergify queue

Copy link

mergify bot commented Aug 19, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 6faa9c6

mergify bot added a commit that referenced this pull request Aug 19, 2024
@mergify mergify bot merged commit 6faa9c6 into sigp:unstable Aug 19, 2024
28 checks passed
AgeManning pushed a commit to AgeManning/lighthouse that referenced this pull request Sep 3, 2024
* Prevent fd leak in random slasher tests

* Clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge. slasher test improvement Improve tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants