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

bug(lib): drop env on last use #2011

Merged
merged 1 commit into from
Jan 4, 2022
Merged

bug(lib): drop env on last use #2011

merged 1 commit into from
Jan 4, 2022

Conversation

MarinPostma
Copy link
Contributor

fixes the too many open files error when running tests by closing the
environment on last drop

To check that we are actually the last owner of the env we plan to drop, I have wrapped all envs in Arc, and check that we have the last reference to it.

Copy link
Member

@Kerollmops Kerollmops left a comment

Choose a reason for hiding this comment

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

That's ok with me, can you just remove this dbg, please?

@@ -90,7 +90,7 @@ pub struct SnapshotJob {

impl SnapshotJob {
pub async fn run(self) -> anyhow::Result<()> {
tokio::task::spawn_blocking(|| self.run_sync()).await??;
tokio::task::spawn_blocking(|| dbg!(self.run_sync())).await??;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tokio::task::spawn_blocking(|| dbg!(self.run_sync())).await??;
tokio::task::spawn_blocking(|| self.run_sync()).await??;

keys: Database<ByteSlice, SerdeJson<Key>>,
action_keyid_index_expiration: Database<KeyIdActionCodec, SerdeJson<Option<DateTime<Utc>>>>,
}

impl Drop for HeedAuthStore {
fn drop(&mut self) {
if Arc::strong_count(&self.env) == 1 {
Copy link
Member

Choose a reason for hiding this comment

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

I consider it safe to check that the count is equal to 1 as there is no way it can grow between the moment you acquire this number and you compare it to 1.

Copy link
Member

@Kerollmops Kerollmops left a comment

Choose a reason for hiding this comment

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

Can you remove the dbg! in the snapshot.rs file, please?

@MarinPostma
Copy link
Contributor Author

Can you remove the dbg! in the snapshot.rs file, please?

My bad I pushed an empty commit --'

fixes the `too many open files` error when running tests by closing the
environment on last drop
Copy link
Member

@Kerollmops Kerollmops left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@Kerollmops
Copy link
Member

bors merge

@bors
Copy link
Contributor

bors bot commented Dec 16, 2021

🕐 Waiting for PR status (Github check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@curquiza curquiza added this to the v0.26.0 milestone Dec 16, 2021
@curquiza
Copy link
Member

bors merge

bors bot added a commit that referenced this pull request Dec 16, 2021
2011: bug(lib): drop env on last use r=curquiza a=MarinPostma

fixes the `too many open files` error when running tests by closing the
environment on last drop

To check that we are actually the last owner of the `env` we plan to drop, I have wrapped all envs in `Arc`, and check that we have the last reference to it.


Co-authored-by: Marin Postma <postma.marin@protonmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 16, 2021

Build failed:

@curquiza
Copy link
Member

bors merge

bors bot added a commit that referenced this pull request Dec 16, 2021
2011: bug(lib): drop env on last use r=curquiza a=MarinPostma

fixes the `too many open files` error when running tests by closing the
environment on last drop

To check that we are actually the last owner of the `env` we plan to drop, I have wrapped all envs in `Arc`, and check that we have the last reference to it.


Co-authored-by: Marin Postma <postma.marin@protonmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 16, 2021

Build failed:

@curquiza
Copy link
Member

curquiza commented Jan 4, 2022

bors merge

@bors
Copy link
Contributor

bors bot commented Jan 4, 2022

@bors bors bot merged commit f56989e into main Jan 4, 2022
@bors bors bot deleted the fix-too-many-open-files branch January 4, 2022 11:24
@curquiza curquiza added the v0.26.0 PRs/issues solved in v0.26.0 label Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v0.26.0 PRs/issues solved in v0.26.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants