rmannibucau opened a new pull request, #9374:
URL: https://github.com/apache/hop/pull/9374

   ## Summary
   
   Fix a monitor deadlock during local pipeline error shutdown, and prevent 
reentrant/concurrent calls from stopping the same pipeline repeatedly.
   
   A JVM thread dump showed this three-thread cycle:
   
   ```text
   TableInput completion:
     holds transform monitor
     -> waits for pipeline monitor in the transform-finished listener
   
   FilterRows completion:
     holds pipeline monitor
     -> waits for transforms-list monitor in transforms.size()
   
   ExecSqlRow error shutdown:
     holds transforms-list monitor in stopAll()/synchronizedList.forEach()
     -> waits for TableInput monitor in stopRunning()
   ```
   
   The SQL exception in `ExecSqlRow` triggers shutdown; the deadlock is in the 
shutdown/completion locking, not the SQL execution itself.
   
   ## Changes
   
   - Iterate snapshots of the transforms in `stopAll()`, `safeStop()` and 
`killAllNoWait()`, so transform callbacks do not run under the synchronized 
transform-list monitor.
   - Atomically claim `stopAll()` before invoking callbacks, preventing 
duplicate concurrent shutdown and recursive shutdown through transform 
callbacks.
   - Keep terminal-state updates in `BaseTransform.markStop()` synchronized, 
but notify finished listeners after releasing the transform monitor.
   - Snapshot the finished listeners and invoke callbacks without holding their 
list monitor. Listeners added during notification participate only in 
subsequent notifications, rather than invalidating the current iteration.
   - Move error-triggered stopping out of the pipeline monitor in the 
completion listener.
   
   ## Regression coverage
   
   Seven new bounded regression tests cover:
   
   - Access to the transform list from another thread while `stopAll()` and 
`safeStop()` execute transform callbacks.
   - Reentrant `stopAll()` from a transform stop callback.
   - Concurrent `stopAll()` calls notifying stopped listeners once.
   - Safe stopping only input transforms, allowing downstream processing to 
drain.
   - Completion callbacks acquiring the transform and listener-list monitors 
from another thread.
   - Concurrent/reentrant `markStop()` and listener registration during 
completion.
   
   ## Validation
   
   Verified with Java 21 on the original development checkout before applying 
the identical four-file patch to this branch:
   
   - `PipelineTest`: 23 tests, zero failures/errors.
   - `BaseTransformTest`: 19 tests, zero failures/errors.
   - The broader engine test/package invocation exceeded the 125-second command 
timeout. Its completed Surefire reports contained 1,054 tests across 176 
reports with zero failures/errors; this is **not** a successful full-suite 
result. The log also included a background timer exception about an 
uninitialized central log store; its relationship to the timeout was not 
established.
   - Subsequent engine packaging with `mvn -q package -DskipTests 
-Dassembly.skipAssembly=true` succeeded.
   - `git diff --check` passed; the patch applied cleanly to current `main`.
   
   The initial test-compilation attempt found a missing import in the new 
tests, which was corrected before the above results. Tests have not been rerun 
on this rebased branch. The production workload and its failure-shutdown path 
have not been replayed with the patched runtime.
   
   This branch contains only the deadlock fix and tests, not the separate Table 
Input JDBC partitioning work.
   
   ---
   
   ### Contribution checklist
   
   - [ ] Run `mvn clean install apache-rat:check` (not performed; validation 
limits above).
   - [x] Keep related changes in a single commit.
   - [ ] Mention an issue if applicable (no separate issue filed).
   - [ ] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) 
(for contributor confirmation during review).
   


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