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

Core: Add AzAffinityAllNodes Read Strategy #2986

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Muhammad-awawdi-amazon
Copy link
Collaborator

@Muhammad-awawdi-amazon Muhammad-awawdi-amazon commented Jan 21, 2025

Issue link

This Pull Request is linked to issue (URL): #2792

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

@Muhammad-awawdi-amazon Muhammad-awawdi-amazon added Feature Additional feature, big or small Rust core redis-rs/glide-core matter labels Jan 21, 2025
@Muhammad-awawdi-amazon Muhammad-awawdi-amazon requested a review from a team as a code owner January 21, 2025 13:40
@@ -302,6 +302,103 @@ mod cluster_async {
);
}

#[tokio::test]
async fn test_routing_by_slot_to_replica_with_az_affinity_all_nodes_strategy_to_half_replicas()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run the exiting test twice, once for AZAffinity and once for the new strategy

@@ -392,6 +489,209 @@ mod cluster_async {
);
}

#[tokio::test]
async fn test_routing_by_slot_to_replica_with_az_affinity_all_nodes_strategy_to_all_replicas() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. use the existing test

let cluster =
TestClusterContext::new((replica_num * primaries_num) + primaries_num, replica_num);
let client_az = "us-east-1a".to_string();
let other_az = "us-east-1b".to_string();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need it. it will be empty string anyway, and different from client az

.route_command(
&cmd,
RoutingInfo::SingleNode(SingleNodeRoutingInfo::SpecificNode(Route::new(
10923, // This should target the third primary
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you not use the same slot as previous tests that mapped to the foo key?

@@ -288,6 +288,64 @@ where
}
}

/// Returns the node's connection in the same availability zone as `client_az`,
/// checking replicas first, then primary, and falling back to any available node.
pub(crate) fn round_robin_read_from_replica_with_az_awareness_all_nodes(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to create a helping function and to use the same logic for both functions with flag, this one and the already exits round_robin_read_from_replica_with_az_awareness function. Both functions logic except of step 2, is duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Additional feature, big or small Rust core redis-rs/glide-core matter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants