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

Remote discovery: fix bug where remote discovery never resyncs remote CGWs #89

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/cgw_remote_discovery.rs
Original file line number Diff line number Diff line change
@@ -996,25 +996,26 @@ impl CGWRemoteDiscovery {
// try to use internal cache first
if let Some(cl) = self.remote_cgws_map.read().await.get(&shard_id) {
if let Err(_e) = cl.client.relay_request_stream(stream).await {
error!(
"Failed to relay message. CGW{} seems to be unreachable at [{}:{}]",
warn!(
"Failed to relay message. CGW{} seems to be unreachable at [{}:{}], will try to resync map and try again",
shard_id, cl.shard.server_host, cl.shard.server_port
);
} else {
return Ok(());
}

return Ok(());
}

// then try to use redis
let _ = self.sync_remote_cgw_map().await;
if let Some(cl) = self.remote_cgws_map.read().await.get(&shard_id) {
if let Err(_e) = cl.client.relay_request_stream(stream).await {
error!(
"Failed to relay message. CGW{} seems to be unreachable at [{}:{}]",
"Failed to relay message event after resync. CGW{} seems to be unreachable at [{}:{}]",
shard_id, cl.shard.server_host, cl.shard.server_port
);
} else {
return Ok(());
}
return Ok(());
}

error!("No suitable CGW instance #{shard_id} was discovered, cannot relay msg");