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 with tokio oneshot #316

Open
ActivePeter opened this issue Nov 23, 2024 · 0 comments
Open

bug with tokio oneshot #316

ActivePeter opened this issue Nov 23, 2024 · 0 comments

Comments

@ActivePeter
Copy link

I implemented concurrent registration and event notification using key_waitings with DashMap and Tokio’s oneshot in the following code:

  • key_waitings: Link
  • Registration of waiters: Link
  • Notification of events: Link

The issue occurs intermittently when running RUST_BACKTRACE=1 cargo test test_kv_user_client -- --nocapture

When I changed the notification code from getting the corresponding oneshot with get_mut from the map to deleting the corresponding oneshot from the map, the issue was resolved.

// if let Some(mut key_waitings) = self.key_waitings.get_mut(key) {
if let Some((_, key_waitings)) = self.key_waitings.remove(key) { // no panic 
    for wait_tx in key_waitings.drain(..) {
        wait_tx
            .send((kvversion, KvValue::RawData(value.clone())))
            .unwrap_or_else(|_| panic!("send new key event failed"));
    }
}
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

No branches or pull requests

1 participant