tarun11Mavani commented on code in PR #17352:
URL: https://github.com/apache/pinot/pull/17352#discussion_r2662433651
##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/MinionTaskUtils.java:
##########
@@ -334,4 +335,49 @@ public static ValidDocIdsType
getValidDocIdsType(UpsertConfig upsertConfig, Map<
}
return validDocIdsType;
}
+
+ /**
+ * Checks if all replicas have consensus on validDoc counts for a segment.
+ * SAFETY LOGIC:
+ * 1. Only proceed with operations when ALL replicas agree on totalValidDocs
count
+ * 2. Skip operations if ANY server hosting the segment is not in READY state
+ * 3. Include all replicas (even those with CRC mismatches) in consensus for
safety
+ *
+ * @param segmentName the name of the segment being checked
+ * @param replicaMetadataList list of metadata from all replicas of the
segment
+ * @return true if all replicas have consensus on validDoc counts, false
otherwise
+ */
+ public static boolean hasValidDocConsensus(String segmentName,
+ List<ValidDocIdsMetadataInfo> replicaMetadataList) {
+
+ if (replicaMetadataList == null || replicaMetadataList.isEmpty()) {
+ LOGGER.warn("No replica metadata available for segment: {}",
segmentName);
+ return false;
+ }
+
+ // Check server readiness for ALL replicas - skip if ANY server is not
ready
+ for (ValidDocIdsMetadataInfo metadata : replicaMetadataList) {
+ if (metadata.getServerStatus() != null &&
!metadata.getServerStatus().equals(ServiceStatus.Status.GOOD)) {
+ LOGGER.warn("Server {} is in {} state for segment: {}, skipping
consensus check",
+ metadata.getInstanceId(), metadata.getServerStatus(), segmentName);
+ return false;
+ }
+ }
+
+ // Check if all replicas have the same totalValidDocs count
+ Long consensusValidDocs = null;
+ for (ValidDocIdsMetadataInfo metadata : replicaMetadataList) {
+ long validDocs = metadata.getTotalValidDocs();
Review Comment:
done
--
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]