Skip to content

name_resolution: include structural attributes in Address PartialEq#2631

Open
nathanielford wants to merge 8 commits intohyperium:masterfrom
nathanielford:refactor/AddressHashing
Open

name_resolution: include structural attributes in Address PartialEq#2631
nathanielford wants to merge 8 commits intohyperium:masterfrom
nathanielford:refactor/AddressHashing

Conversation

@nathanielford
Copy link
Copy Markdown
Collaborator

This PR is for the grpc-Rust official library, and not for tonic.

Motivation

In the process of writing the Pick First LB policy, I realized that there were edge cases characterized by the following:

  • The name resolver provides a new list of addresses
  • Some of those addresses match to the previous list of addresses based on the hashed fields, even though they should not because they have different attribute fields, causing a false positive match.

The reason for this is that the addresses cannot be included in the hashing, because they are type-erased. I think all load balancers are likely to run into this issue.

Solution

Updating PartialEq in order to validate that the address attributes are equal in addition to the network type and address field. This means new Addresses with different attributes should be hashed into the same bucket but that looking an address with attribute set A will not fetch an address with attribute set B.

There may be a better way to handle this, or a reason it hasn't been done already - I'd be grateful for any feedback that anyone can provide on this front.

@nathanielford nathanielford requested a review from dfawley May 6, 2026 23:31
Copy link
Copy Markdown
Collaborator

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

I don't recall if there is a reason it was like this before, but this SGTM.

Can we not derive(PartialEq,Eq)? (If not why not?)

@nathanielford
Copy link
Copy Markdown
Collaborator Author

No reason not to use derive! I just didn't think of it right off since I was in the weeds. Have fixed that. Also included a perhaps not needed unit test in order to at least capture the thinking. If we feel it's not worth the bytes, though, I can pull it.

Comment thread grpc/src/client/name_resolution/mod.rs Outdated
Comment thread grpc/src/client/name_resolution/mod.rs Outdated
Comment thread grpc/src/client/name_resolution/mod.rs Outdated
Comment thread grpc/src/client/name_resolution/mod.rs Outdated
@nathanielford nathanielford enabled auto-merge (squash) May 7, 2026 16:32
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 this pull request may close these issues.

2 participants