saurabhd336 commented on code in PR #8663: URL: https://github.com/apache/pinot/pull/8663#discussion_r875514876
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java: ########## @@ -1147,13 +1155,34 @@ IdealState ensureAllPartitionsConsuming(TableConfig tableConfig, PartitionLevelS } else { if (newPartitionGroupSet.contains(partitionGroupId)) { // If we get here, that means in IdealState, the latest segment has no CONSUMING replicas, but has - // replicas - // not OFFLINE. That is an unexpected state which cannot be fixed by the validation manager currently. In - // that case, we need to either extend this part to handle the state, or prevent segments from getting - // into - // such state. - LOGGER - .error("Got unexpected instance state map: {} for segment: {}", instanceStateMap, latestSegmentName); + // replicas not OFFLINE. Create a new IN_PROGRESS segment in PROPERTYSTORE, + // add it as CONSUMING segment to IDEALSTATE. Currently, only enabled via /resumeConsumption API + + if (enforcedByAdmin) { + LLCSegmentName newLLCSegmentName = getNextLLCSegmentName(latestLLCSegmentName, currentTimeMs); + StreamPartitionMsgOffset startOffset = offsetFactory.create(latestSegmentZKMetadata.getEndOffset()); + StreamPartitionMsgOffset partitionGroupSmallestOffset = + getPartitionGroupSmallestOffset(streamConfig, partitionGroupId); + + // Start offset must be higher than the start offset of the stream + if (partitionGroupSmallestOffset.compareTo(startOffset) > 0) { + LOGGER.error("Data lost from offset: {} to: {} for partition: {} of table: {}", startOffset, + partitionGroupSmallestOffset, partitionGroupId, realtimeTableName); + _controllerMetrics.addMeteredTableValue(realtimeTableName, ControllerMeter.LLC_STREAM_DATA_LOSS, 1L); + startOffset = partitionGroupSmallestOffset; + } + CommittingSegmentDescriptor committingSegmentDescriptor = + new CommittingSegmentDescriptor(null, startOffset.toString(), 0); + createNewSegmentZKMetadata(tableConfig, streamConfig, newLLCSegmentName, currentTimeMs, + committingSegmentDescriptor, latestSegmentZKMetadata, instancePartitions, numPartitions, + numReplicas, newPartitionGroupMetadataList); + String newSegmentName = newLLCSegmentName.getSegmentName(); + updateInstanceStatesForNewConsumingSegment(instanceStatesMap, null, newSegmentName, segmentAssignment, + instancePartitionsMap); Review Comment: Added a new function for this -- 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