Release classloaders after failed task deployment
Fixed SeaTunnel Zeta task deployment cleanup so classloader references acquired during a failed, partially constructed task group are released before control returns to the engine.
apache/seatunnel · #11812
Zeta engine reliability fix
Failed task deployments now release every classloader reference they acquired, preventing failure history from accumulating metaspace pressure and open JAR handles.
Problem
`TaskExecutionService.deployTask` acquired a reference-counted classloader for each task while constructing a group. If deserialization or context initialization failed before `TaskGroupContext` was published, normal lifecycle cleanup had no context to own those references, allowing repeated bad deployments to retain metaspace and JAR file handles.
Approach
Tracked every classloader reference acquired by the current deployment attempt, released still-owned references after pre-publication failure, and treated context publication as a monotonic ownership transfer. Cleanup continues across failures while preserving the original deployment exception, and short-lived published tasks avoid a second release even if their context disappears before deployment returns.
Impact and scope
- Prevents malformed payloads, incompatible task data, and partial initialization failures from creating a cumulative classloader resource leak.
- Keeps acquisition and release counts balanced without closing classloaders still owned by concurrent or successfully published task groups.
- Preserves the original failure for diagnosis while attaching cleanup failures as suppressed exceptions and attempting every remaining release.
Validation
- Added regression coverage for task deserialization failure and task-context initialization failure before context publication.
- Verified no context is published, acquired reference counts return to zero, and failed deployment state still reaches the master; all 15 focused engine tests passed.
- Received seven approvals from three maintainers; the final merge commit is GitHub-verified, credits Goutam Adwant, and closed GH-11808 as completed.