You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/12/09 20:16:38 UTC

[GitHub] [pinot] mcvsubbu commented on a change in pull request #7886: BUG FIX: semaphore issue in consuming segments

mcvsubbu commented on a change in pull request #7886:
URL: https://github.com/apache/pinot/pull/7886#discussion_r766123327



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java
##########
@@ -340,9 +340,18 @@ public void addSegment(String segmentName, TableConfig tableConfig, IndexLoading
       PartitionUpsertMetadataManager partitionUpsertMetadataManager =
           _tableUpsertMetadataManager != null ? _tableUpsertMetadataManager
               .getOrCreatePartitionManager(partitionGroupId) : null;
-      segmentDataManager =
-          new LLRealtimeSegmentDataManager(segmentZKMetadata, tableConfig, this, _indexDir.getAbsolutePath(),
-              indexLoadingConfig, schema, llcSegmentName, semaphore, _serverMetrics, partitionUpsertMetadataManager);
+      try {
+        segmentDataManager =
+            new LLRealtimeSegmentDataManager(segmentZKMetadata, tableConfig, this, _indexDir.getAbsolutePath(),
+                indexLoadingConfig, schema, llcSegmentName, semaphore, _serverMetrics, partitionUpsertMetadataManager);
+      } catch (Exception e) {
+        // In case of exception thrown here, segment goes to ERROR state. Then any attempt to reset the segment from
+        // ERROR -> OFFLINE -> CONSUMING via Helix Admin fails because the semaphore never gets released and the
+        // semaphore.acquire() is called in constructor of LLRealtimeSegmentDataManager. Hence releasing the semaphore
+        // here to unblock reset operation via Helix Admin.
+        semaphore.release();
+        throw e;

Review comment:
       Agreed. It is confusing to acquire in one place and release some place else. 
   
   Perhaps a try/catch on all lines after the semahore (or any other resource) is acquired, so that if any exceptions are thrown, these can be released.
   




-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org