abhishekrb19 commented on code in PR #16362:
URL: https://github.com/apache/druid/pull/16362#discussion_r1586959462


##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java:
##########
@@ -346,4 +347,24 @@ public LookupLoadingSpec getLookupLoadingSpec()
   {
     return LookupLoadingSpec.NONE;
   }
+
+  @Override
+  public boolean isReady(TaskActionClient taskActionClient) throws Exception
+  {
+    final boolean isUsingConcurrentLocks = Boolean.TRUE.equals(
+        getContextValue(
+            Tasks.USE_CONCURRENT_LOCKS,
+            Tasks.DEFAULT_USE_CONCURRENT_LOCKS
+        )
+    );
+
+    TaskLockType defaultLockType = !markAsUnused && isUsingConcurrentLocks ? 
TaskLockType.REPLACE : TaskLockType.EXCLUSIVE;
+
+    TaskLockType actualLockType = getContextValue(Tasks.TASK_LOCK_TYPE, 
defaultLockType);
+
+    if (markAsUnused && actualLockType != TaskLockType.EXCLUSIVE) {

Review Comment:
   `markAsUnused` is undocumented and has been deprecated for a few releases 
since Druid 28. Instead of expanding on the legacy flag, we can remove it for 
Druid 31. It should simplify this code and related testing a bit. cc: @kfaraz 
   
   @IgorBerman, would you be interested in doing that in a separate PR?



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/AbstractFixedIntervalTask.java:
##########
@@ -77,10 +77,15 @@ protected AbstractFixedIntervalTask(
 
   @Override
   public boolean isReady(TaskActionClient taskActionClient) throws Exception
+  {
+    return isReady(taskActionClient, TaskLockType.EXCLUSIVE);
+  }
+
+  protected boolean isReady(TaskActionClient taskActionClient, TaskLockType 
taskLockType) throws Exception

Review Comment:
   Can we leave the base implementation as it is, without adding this extra 
protected method? The logic is simple enough for child class implementations to 
fully override `isReady()` without calling `super.isReady()`



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java:
##########
@@ -346,4 +347,24 @@ public LookupLoadingSpec getLookupLoadingSpec()
   {
     return LookupLoadingSpec.NONE;
   }
+
+  @Override
+  public boolean isReady(TaskActionClient taskActionClient) throws Exception
+  {
+    final boolean isUsingConcurrentLocks = Boolean.TRUE.equals(

Review Comment:
   ```suggestion
       final boolean useConcurrentLocks = Boolean.TRUE.equals(
   ```
   
   Also, when you're adding tests, could you please add docs for this task 
context?



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTask.java:
##########
@@ -341,6 +342,15 @@ private NavigableMap<DateTime, List<TaskLock>> 
getNonRevokedTaskLockMap(TaskActi
     return taskLockMap;
   }
 
+  @Override
+  public boolean isReady(TaskActionClient taskActionClient) throws Exception
+  {
+    if (markAsUnused) {
+      return super.isReady(taskActionClient);
+    }
+    return super.isReady(taskActionClient, 
getContextValue(Tasks.TASK_LOCK_TYPE, TaskLockType.SHARED));

Review Comment:
   Yeah, I see what you mean. With the follow up discussion to use exclusive 
lock by default and replace lock in the concurrent case, this won't be a 
concern anymore, right?



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