davidzollo commented on PR #11757:
URL: https://github.com/apache/seatunnel/pull/11757#issuecomment-5549209322

   ## Closed the FAILED-fallthrough gap Daniel flagged
   
   Pushed `4336d46`, which fixes the gap in Issue 1: `finishOwnedResources()` 
(the `completionLatch==0` path) already checks that a tracker still owns the 
active `TaskGroupContext` before touching 
`taskAsyncFunctionFuture`/`timerFlushFutures`, but `cancelAllTask()` had no 
such guard — and it's reachable two other ways that skip that check entirely:
   
   1. `taskDone()`'s FAILED-fallthrough, whenever *any* task in the group fails 
while the group isn't cancelled — including when `completionLatch` hasn't 
reached zero yet, i.e. a sibling task can still fail after this tracker's own 
generation has already lost the ownership race.
   2. The `cancellationFuture.whenComplete()` handler installed in the 
constructor.
   
   In both cases a stale tracker would unconditionally cancel and remove 
whatever `taskAsyncFunctionFuture`/`timerFlushFutures` entries currently sit 
under its `TaskGroupLocation` — which, after a restore, belong to the newer 
generation. Same corruption class this PR exists to fix, just a different call 
path than the one already covered.
   
   **Fix:** `cancelAllTask()` now takes the same `synchronized 
(TaskExecutionService.this)` ownership check `finishOwnedResources()` already 
uses, guarding only the two shared, location-keyed calls 
(`cancelAsyncFunction`, `cancelTimerFlushForTaskGroup`). The 
per-tracker-private `blockingFutures`/`currRunningTaskFuture` cancellation 
above it is untouched, since those are never shared across generations. Fixing 
it centrally in `cancelAllTask()` covers both call sites in one change rather 
than patching `taskDone()` alone.
   
   **Test:** added 
`testStaleFailedTaskDoneDoesNotCleanupNewerGenerationResources`, using a 
two-task old-generation group and failing only the first task so 
`completionLatch` never reaches zero — isolating the FAILED-fallthrough path 
from `finishOwnedResources()`'s already-guarded branch, per Daniel's exact 
critique of the existing test 
(`testStaleTaskDoneDoesNotCleanupNewerGenerationResources` uses a single 
always-successful task and never exercises this path).
   
   @DanielLeens — over to you for a fresh from-scratch review of the cleaned 
head.
   


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

Reply via email to