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

[Dev]: Deadlocks #32

Closed
TylerBloom opened this issue Jul 6, 2022 · 3 comments
Closed

[Dev]: Deadlocks #32

TylerBloom opened this issue Jul 6, 2022 · 3 comments
Assignees
Labels
bug Something isn't working in progress Actively being worked on

Comments

@TylerBloom
Copy link
Member

TylerBloom commented Jul 6, 2022

I thought that I was careful and avoided opportunities for deadlocks. I was incorrect. Both DashMap::get() and DashMap::get_mut() can deadlock, which are used extensively. This should be rare but was the core issue behind #23. Either a more measured approach to acquisition needs to be implemented or those maps need to be swapped for an async type.

@TylerBloom TylerBloom added bug Something isn't working in progress Actively being worked on labels Jul 6, 2022
@TylerBloom TylerBloom added this to the Version 2.0 Release milestone Jul 6, 2022
@TylerBloom TylerBloom self-assigned this Jul 6, 2022
@TylerBloom TylerBloom mentioned this issue Jul 6, 2022
@TylerBloom
Copy link
Member Author

A decent alternative to DashMap would be tokio::sync::RwLock<HashMap>. This would allow for all maps to be fully async.

@TylerBloom
Copy link
Member Author

TylerBloom commented Jul 8, 2022

Because the throughput required of any given item in a DashMap is at most on the order of 100 requests per hour, a simple async spin lock should suffice. See b60bbe4 for the implementation of said spin lock.

@TylerBloom
Copy link
Member Author

This was almost entirely addressed in dc426c9. There is still one outstanding issue that doesn't have an apparent solution. DashMap::insert can cause a deadlock; however, it doesn't have a 'try' counterpart like the get methods. So, a spin lock can't be used. The chances of this causing problems are very small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in progress Actively being worked on
Projects
Development

No branches or pull requests

1 participant