Copilot commented on code in PR #15672:
URL: https://github.com/apache/pinot/pull/15672#discussion_r2066768712


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessor.java:
##########
@@ -130,7 +130,14 @@ public void process(@Nullable SegmentOperationsThrottler 
segmentOperationsThrott
         if (type != StandardIndexes.forward()) {
           IndexHandler handler = createHandler(type);
           indexHandlers.add(handler);
-          handler.updateIndices(segmentWriter);
+          try {
+            handler.updateIndices(segmentWriter);
+          } catch (Exception e) {
+            // If the index creation fails, we need to remove the index files 
created so far.
+            // This is because the index creation may have modified the 
segment metadata and we need to revert it.
+            LOGGER.error("Failed to create index: {} for segment: {}", type, 
_segmentMetadata.getName(), e);
+            indexHandlers.remove(handler);

Review Comment:
   [nitpick] Consider catching a more specific exception type instead of 
Exception to avoid inadvertently swallowing unexpected errors.
   ```suggestion
             } catch (IOException e) {
               // If the index creation fails due to an IO error, we need to 
remove the index files created so far.
               // This is because the index creation may have modified the 
segment metadata and we need to revert it.
               LOGGER.error("IO error while creating index: {} for segment: 
{}", type, _segmentMetadata.getName(), e);
               indexHandlers.remove(handler);
             } catch (RuntimeException e) {
               // Handle unexpected runtime exceptions separately to avoid 
masking critical issues.
               LOGGER.error("Unexpected error while creating index: {} for 
segment: {}", type, _segmentMetadata.getName(), e);
               throw e;
   ```



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