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

Dashmap get_mut sometimes block thread #33

Closed
Kumassy opened this issue Aug 20, 2022 · 2 comments · Fixed by #36
Closed

Dashmap get_mut sometimes block thread #33

Kumassy opened this issue Aug 20, 2022 · 2 comments · Fixed by #36

Comments

@Kumassy
Copy link
Owner

Kumassy commented Aug 20, 2022

In certain situation, get_mut exhausts entire CPU.

match self.clients.get_mut(&client_id) {
Some(mut client) => {
client.send_to_client(packet).await
},
None => {
Err(ClientStreamError::ClientNotAvailable(client_id))
}
}

Use try_get_mut of DashMap 5
https://docs.rs/dashmap/latest/dashmap/struct.DashMap.html#method.try_get_mut

This was referenced Aug 21, 2022
@Kumassy
Copy link
Owner Author

Kumassy commented Aug 21, 2022

In async code, dashmap sometimes causes deadlock

This is a known issue. It stems from the fact that you are keeping a Ref guard bound to _ across an await point which may deadlock. The v4 release does fix this issue and will be coming out in May.

xacrimon/dashmap#79

DashMap 5.3.4 still have the problem, so we should use RwLock<HashMap<K,V>> for now.

@x1957
Copy link

x1957 commented Dec 10, 2022

In async code, dashmap sometimes causes deadlock

This is a known issue. It stems from the fact that you are keeping a Ref guard bound to _ across an await point which may deadlock. The v4 release does fix this issue and will be coming out in May.

xacrimon/dashmap#79

DashMap 5.3.4 still have the problem, so we should use RwLock<HashMap<K,V>> for now.

Does 5.4 still have the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants