saurabhd336 commented on code in PR #12276:
URL: https://github.com/apache/pinot/pull/12276#discussion_r1456908831


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/BalancedInstanceSelector.java:
##########
@@ -89,7 +91,13 @@ Pair<Map<String, String>, Map<String, String>> 
select(List<String> segments, int
         if (candidates == null) {
           continue;
         }
-        int selectedIdx = requestId++ % candidates.size();
+        int selectedIdx;
+        if (_useStickyRouting || 
QueryOptionsUtils.isUseStickyRouting(queryOptions)) {
+          // candidates array is always sorted
+          selectedIdx = Math.abs(_tableNameWithType.hashCode() % 
candidates.size());

Review Comment:
   I think you meant single server?
   And yes, the requirement is to ensure same set of servers are picked for 
queries that are run with this query option set to true.
   What we're trying to achieve is essentially ensure a consistent view of the 
data across queries which may be a requirement for a certain usecases.
   Since the current set of instance selectors essentially round robin / 
randomly pick any of the avaliable servers, sometimes it's possible to see 
query result inconsistencies across queries due to for example the consuming 
segment on one of the replicas lagging behind another replica.
   
   This option ensures we always route to same set of servers therefore for the 
particular subset of queries with this option set, always see a consistent view 
of the data (unless ofcourse the assignment changes / server restarts and is 
catching up / segments are deleted etc, which has been called out explicitly in 
the PR)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to