yashmayya commented on code in PR #20313:
URL: https://github.com/apache/pinot/pull/20313#discussion_r4648097935


##########
pinot-core/src/main/java/org/apache/pinot/core/routing/SegmentsToQuery.java:
##########
@@ -47,4 +60,26 @@ public List<String> getSegments() {
   public List<String> getOptionalSegments() {
     return _optionalSegments;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (!(o instanceof SegmentsToQuery)) {
+      return false;
+    }
+    SegmentsToQuery that = (SegmentsToQuery) o;
+    return _segments.equals(that._segments) && 
_optionalSegments.equals(that._optionalSegments);

Review Comment:
   Small: the 2-argument constructor accepts a null `optionalSegments`. 
`ImplicitHybridTableRouteInfo` and `LogicalTableRouteInfo` allow null, and 
`MockRoutingManagerFactory` passed null before this PR. This `equals` and the 
new readers in this PR throw an NPE on null. All producers in this repo pass a 
list today.
   
   Suggestion: change null to `List.of()` in the constructor.



##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/SegmentStates.java:
##########
@@ -124,6 +124,18 @@ public boolean isUnavailable(int groupId) {
     return _routings[groupId].getNumCandidates() == 0 && 
!_segmentGroups._groups[groupId]._new;
   }
 
+  /// Returns whether the given segment is a new segment that an enabled 
instance might not have loaded yet: it is not
+  /// online on all of its enabled candidates, or it is not tracked yet, which 
a segment only is while it is being
+  /// added, because the routing components learn about it one after another.
+  public boolean isNewAndNotFullyOnline(String segment) {
+    int groupId = getGroupId(segment);
+    if (groupId == UNKNOWN_SEGMENT) {
+      return true;
+    }
+    GroupRouting routing = _routings[groupId];
+    return routing.getNumCandidates() > 0 ? !routing._allOnline : 
_segmentGroups._groups[groupId]._new;

Review Comment:
   `_new` changes only on the next ideal state or external view change of the 
table (see the TODO in the `BaseInstanceSelector` class doc). On a quiet table 
with one slow replica, the segment stays optional after the 5-minute limit. The 
replicated leaf then gives a partial join with no time limit.
   
   Suggestion: in `selectOnAllInstances`, compare `_newSegmentCreationTimeMap` 
with the clock. After the limit, return the segment as a required segment.



-- 
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