jtuglu1 commented on code in PR #18463:
URL: https://github.com/apache/druid/pull/18463#discussion_r2314847923


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskLockbox.java:
##########
@@ -524,7 +523,9 @@ public List<SegmentAllocateResult> allocateSegments(
 
   /**
    * Marks the segment allocation as failed if the underlying task is not 
active.
+   * Should be called only while holding the {@code giant} lock.
    */
+  @GuardedBy("giant")

Review Comment:
   Yes, that's what I was referring to. No, `getActiveTasks()` is not the only 
uncovered path (`remove()` is also, according to SureFire). Adding this 
annotation to that member causes other errors:
   ```
   [ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) 
on project druid-indexing-service: Compilation failure
   [ERROR] 
druid/indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskLockbox.java:[1246,8]
 error: [GuardedBy] This access should be guarded by 'this.giant', which is not 
currently held
   [ERROR]     (see https://errorprone.info/bugpattern/GuardedBy)
   ```
   
   It seems that it doesn't like:
   ```java
   if (task != null) {
           activeTasks.remove(task.getId());
   }
   ```
   being called in the finally.
   
   Doing something like:
   ```java
       giant.lock();
       try {
         try {
           if (!activeTasks.contains(task.getId())) {
             return;
           }
           log.info("Removing task[%s] from activeTasks", task.getId());
           cleanupUpgradeAndPendingSegments(task);
           unlockAll(task);
         }
         finally {
           if (task != null) {
             activeTasks.remove(task.getId());
           }
         }
       }
       finally {
         giant.unlock();
       }
   ```
   works, however.
   
   I can also disable the check on this specific function.



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