Skip to content

Conversation

@boda26
Copy link
Collaborator

@boda26 boda26 commented Oct 20, 2025

Initial design of cluster map interface. This interface enables instant retrieval of cluster slot status, shard info and fingerprints, and primary/replica/random node targets.

@boda26 boda26 requested a review from allenss-amazon October 20, 2025 17:28
bool IsSlotOwned(uint16_t slot) const;

// shard lookups
const ShardInfo* GetShardById(const std::string& shard_id) const;
Copy link
Member

Choose a reason for hiding this comment

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

How is shard-not-found signalled? Also, use string_view to pass in string parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If shard not found then this function would return nullptr. Another choice is to return std::optional

primary_targets_;
std::vector<valkey_search::query::fanout::FanoutSearchTarget>
replica_targets_;
std::vector<valkey_search::query::fanout::FanoutSearchTarget> random_targets_;
Copy link
Member

Choose a reason for hiding this comment

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

does random_targets make sense here? How do we randomize from one call to the next call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For here I think kRandom would just return the same set of nodes in a certain period. When the CreateNewClusterMap being called and refresh the cluster map, another set of random nodes are get selected.

Comment on lines 62 to 66
// Pre-computed target lists
std::vector<valkey_search::query::fanout::FanoutSearchTarget>
primary_targets_;
std::vector<valkey_search::query::fanout::FanoutSearchTarget>
replica_targets_;
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any interfaces that get any of these. Also, in looking at FanoutSearchTarget, I'm wondering how that's different from some per-Node information structure which belongs to this class. I'd recommend moving that struct into this class and naming it something like NodeInfo (parallel to ShardInfo).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can create a NodeInfo Struct in this class. Also all the current FanoutSearchTarget code can be moved entirely into the cluster map object, including the selection of nodes (kPrimary/kReplica/kRandom/kAll)

@boda26 boda26 requested a review from allenss-amazon October 20, 2025 21:38
std::string shard_id;
std::string primary_address;
std::vector<std::string> replica_addresses;
std::vector<uint16_t> owned_slots;
Copy link
Member

Choose a reason for hiding this comment

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

I believe an ordered set would be more useful than a vector. When you fingerprint, it will eliminate any order dependency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should it be an unordered_set or a set here, is the order matter here?

// Pre-computed target lists
std::vector<NodeInfo> primary_targets_;
std::vector<NodeInfo> replica_targets_;
std::vector<NodeInfo> random_targets_;
Copy link
Member

Choose a reason for hiding this comment

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

You're proposing to tie the update frequency of the random_targets_ to a particular time-rate (the rate at which the overall ClusterMap is regenerated). This suggests a relationship between the time-rate and the duration of the search operations. What time-rate were you targetting? What is the expected duration of the search operations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's discuss this in meeting

Signed-off-by: Miles Song <[email protected]>
@boda26 boda26 closed this Oct 24, 2025
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