siddiqueirshad opened a new pull request, #20780:
URL: https://github.com/apache/druid/pull/20780

   ### Description of changes
   
   Fixes #20773.
   
   When `HttpRemoteTaskRunner.shutdown()` is called for a task in the 
`PENDING_WORKER_ASSIGN` state, it removes the task from `pendingTaskIds` to 
prevent other threads from scheduling it.
   
   However, if `runTaskOnWorker()` subsequently returns `false` (which occurs 
if the candidate worker was removed, marked lazy or blacklisted, or disabled), 
the assigning thread reverted the item back to `PENDING` via 
`revertStateFromPendingWorkerAssignToPending()`. Because the `taskId` was 
already removed from `pendingTaskIds`, the task was never picked up again for 
assignment, and remained pending with an open result future until a later 
`TaskQueue` management cycle forced a shutdown.
   
   ### Key Changes
   - Added `shutdownReason` tracking to `HttpRemoteTaskRunnerWorkItem`.
   - In `shutdown()`, when an item is in `PENDING_WORKER_ASSIGN`, record the 
`shutdownReason`.
   - In `assignTasks()`, if `runTaskOnWorker()` fails and 
`taskItem.isShutdownRequested()` is `true`, complete the task immediately as 
failed via `taskComplete(...)` rather than reverting the state back to 
`PENDING`.
   - Added unit test 
`testShutdownTaskBeingAssignedCompletesWhenAssignmentFails()` in 
`HttpRemoteTaskRunnerTest`.
   
   Fixes #20773
   


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