vvivekiyer commented on a change in pull request #8110:
URL: https://github.com/apache/pinot/pull/8110#discussion_r798123284



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/api/upload/ZKOperator.java
##########
@@ -232,15 +240,27 @@ private void processNewSegment(SegmentMetadata 
segmentMetadata, URI finalSegment
             .info("Moved segment {} from temp location {} to {}", segmentName, 
currentSegmentLocation.getAbsolutePath(),
                 finalSegmentLocationURI.getPath());
       } catch (Exception e) {
+        // Cleanup the Zk entry and the segment from the permanent directory 
if it exists.
         LOGGER
             .error("Could not move segment {} from table {} to permanent 
directory", segmentName, tableNameWithType, e);
+        _pinotHelixResourceManager.deleteSegment(tableNameWithType, 
segmentName);
         throw new RuntimeException(e);
       }
     } else {
       LOGGER.info("Skipping segment move, keeping segment {} from table {} at 
{}", segmentName, tableNameWithType,
           zkDownloadURI);
     }
-    _pinotHelixResourceManager.addNewSegment(tableNameWithType, 
segmentMetadata, zkDownloadURI, crypter);
+
+    try {
+      _pinotHelixResourceManager.assignTableSegment(tableNameWithType, 
segmentMetadata.getName());
+    } catch (Exception e) {
+      // assignTableSegment removes the zk entry. Call deleteSegment to remove 
the segment from permanent location.
+      LOGGER
+          .error("Caught exception while calling assignTableSegment for adding 
segment: {} to table: {}", segmentName,
+              tableNameWithType, e);
+      _pinotHelixResourceManager.deleteSegment(tableNameWithType, segmentName);

Review comment:
       Done.

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/api/upload/ZKOperator.java
##########
@@ -232,15 +240,27 @@ private void processNewSegment(SegmentMetadata 
segmentMetadata, URI finalSegment
             .info("Moved segment {} from temp location {} to {}", segmentName, 
currentSegmentLocation.getAbsolutePath(),
                 finalSegmentLocationURI.getPath());
       } catch (Exception e) {
+        // Cleanup the Zk entry and the segment from the permanent directory 
if it exists.
         LOGGER
             .error("Could not move segment {} from table {} to permanent 
directory", segmentName, tableNameWithType, e);
+        _pinotHelixResourceManager.deleteSegment(tableNameWithType, 
segmentName);
         throw new RuntimeException(e);
       }
     } else {
       LOGGER.info("Skipping segment move, keeping segment {} from table {} at 
{}", segmentName, tableNameWithType,
           zkDownloadURI);
     }
-    _pinotHelixResourceManager.addNewSegment(tableNameWithType, 
segmentMetadata, zkDownloadURI, crypter);
+
+    try {
+      _pinotHelixResourceManager.assignTableSegment(tableNameWithType, 
segmentMetadata.getName());
+    } catch (Exception e) {
+      // assignTableSegment removes the zk entry. Call deleteSegment to remove 
the segment from permanent location.
+      LOGGER
+          .error("Caught exception while calling assignTableSegment for adding 
segment: {} to table: {}", segmentName,
+              tableNameWithType, e);
+      _pinotHelixResourceManager.deleteSegment(tableNameWithType, segmentName);
+      throw new RuntimeException(e);

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

Reply via email to