Skip to content

Commit

Permalink
fixed infinite set keyspace notification loop
Browse files Browse the repository at this point in the history
fixes #100
  • Loading branch information
krojew committed Jul 26, 2022
1 parent ef10b0d commit bc021f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cdrs-tokio/src/cluster/config_tcp.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cassandra_protocol::authenticators::{NoneAuthenticatorProvider, SaslAuthenticatorProvider};
use cassandra_protocol::error::Result;
use cassandra_protocol::frame::Version;
use std::net::SocketAddr;
use std::sync::Arc;

use crate::cluster::NodeAddress;
use cassandra_protocol::authenticators::{NoneAuthenticatorProvider, SaslAuthenticatorProvider};
use cassandra_protocol::error::Result;
use cassandra_protocol::frame::Version;

/// Single node TCP connection config.
#[derive(Clone)]
Expand Down
17 changes: 15 additions & 2 deletions cdrs-tokio/src/cluster/keyspace_holder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,25 @@ impl KeyspaceHolder {

#[inline]
pub fn update_current_keyspace(&self, keyspace: String) {
self.update_current_keyspace_without_notification(keyspace.clone());
let _ = self.keyspace_sender.send(Some(keyspace));
let old_keyspace = self.current_keyspace.swap(Some(Arc::new(keyspace.clone())));
match &old_keyspace {
None => {
self.send_notification(keyspace);
}
Some(old_keyspace) if **old_keyspace != keyspace => {
self.send_notification(keyspace);
}
_ => {}
}
}

#[inline]
pub fn update_current_keyspace_without_notification(&self, keyspace: String) {
self.current_keyspace.store(Some(Arc::new(keyspace)));
}

#[inline]
fn send_notification(&self, keyspace: String) {
let _ = self.keyspace_sender.send(Some(keyspace));
}
}
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* `ExponentialReconnectionSchedule` duration overflow.
* Forgetting real error type in certain transport error situations.
* Not sending re-preparation statements to correct nodes.
* Infinite set keyspace notification loop.

### New

Expand Down

0 comments on commit bc021f4

Please sign in to comment.