KKcorps commented on code in PR #14920: URL: https://github.com/apache/pinot/pull/14920#discussion_r1941044749
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -2096,6 +2104,131 @@ URI createSegmentPath(String rawTableName, String segmentName) { return URIUtils.getUri(_controllerConf.getDataDir(), rawTableName, URIUtils.encode(segmentName)); } + /** + * Re-ingests segments that are in ERROR state in EV but ONLINE in IS with no peer copy on any server. This method + * will call the server reIngestSegment API + * on one of the alive servers that are supposed to host that segment according to IdealState. + * + * API signature: + * POST http://[serverURL]/reIngestSegment + * Request body (JSON): + * { + * "tableNameWithType": [tableName], + * "segmentName": [segmentName] + * } + * + * @param tableNameWithType The table name with type, e.g. "myTable_REALTIME" + */ + public void reIngestSegmentsWithErrorState(String tableNameWithType) { + // Step 1: Fetch the ExternalView and all segments + ExternalView externalView = getExternalView(tableNameWithType); + IdealState idealState = getIdealState(tableNameWithType); + Map<String, Map<String, String>> segmentToInstanceCurrentStateMap = externalView.getRecord().getMapFields(); + Map<String, Map<String, String>> segmentToInstanceIdealStateMap = idealState.getRecord().getMapFields(); + + // find segments in ERROR state in externalView + List<String> segmentsInErrorState = new ArrayList<>(); + for (Map.Entry<String, Map<String, String>> entry : segmentToInstanceCurrentStateMap.entrySet()) { + String segmentName = entry.getKey(); + Map<String, String> instanceStateMap = entry.getValue(); + boolean allReplicasInError = true; Review Comment: `When there are ONLINE replica, ideally we should reset the ERROR replica. Do we rely on validation manager for that?` yes that is already a part of validation manager https://github.com/apache/pinot/pull/14217/files -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org