kfaraz commented on code in PR #16393:
URL: https://github.com/apache/druid/pull/16393#discussion_r1591762325


##########
indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentTransactionalReplaceAction.java:
##########
@@ -116,50 +117,56 @@ public TypeReference<SegmentPublishResult> 
getReturnTypeReference()
   @Override
   public SegmentPublishResult perform(Task task, TaskActionToolbox toolbox)
   {
-    TaskLocks.checkLockCoversSegments(task, toolbox.getTaskLockbox(), 
segments);
-
-    // Find the active replace locks held only by this task
-    final Set<ReplaceTaskLock> replaceLocksForTask
-        = toolbox.getTaskLockbox().findReplaceLocksForTask(task);
-
-    final SegmentPublishResult publishResult;
+    final TaskLockbox taskLockbox = toolbox.getTaskLockbox();
+    TaskLocks.checkLockCoversSegments(task, taskLockbox, segments);
+    taskLockbox.acquireTransactionalReplaceLock(task);
     try {
-      publishResult = toolbox.getTaskLockbox().doInCriticalSection(
-          task,
-          
segments.stream().map(DataSegment::getInterval).collect(Collectors.toSet()),
-          CriticalAction.<SegmentPublishResult>builder()
-              .onValidLocks(
-                  () -> toolbox.getIndexerMetadataStorageCoordinator()
-                               .commitReplaceSegments(segments, 
replaceLocksForTask, segmentSchemaMapping)
-              )
-              .onInvalidLocks(
-                  () -> SegmentPublishResult.fail(
-                      "Invalid task locks. Maybe they are revoked by a higher 
priority task."
-                      + " Please check the overlord log for details."
-                  )
-              )
-              .build()
-      );
-    }
-    catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-
-    IndexTaskUtils.emitSegmentPublishMetrics(publishResult, task, toolbox);
+      // Find the active replace locks held only by this task
+      final Set<ReplaceTaskLock> replaceLocksForTask
+          = toolbox.getTaskLockbox().findReplaceLocksForTask(task);
 
-    // Upgrade any overlapping pending segments
-    // Do not perform upgrade in the same transaction as replace commit so that
-    // failure to upgrade pending segments does not affect success of the 
commit
-    if (publishResult.isSuccess() && toolbox.getSupervisorManager() != null) {
+      final SegmentPublishResult publishResult;
       try {

Review Comment:
   Why are there two try blocks now?



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

Reply via email to