joeyutong opened a new issue, #941: URL: https://github.com/apache/flink-agents/issues/941
### Search before asking - [x] I searched in the [issues](https://github.com/apache/flink-agents/issues) and found nothing similar. ### Description After a task failover, Flink may materialize the same job's Python dependencies under a new temporary `python-dist-*` directory. The recovered task is expected to import user code and package resources from that new directory. When the TaskManager JVM survives the failover, however, Pemja's process-level main interpreter can survive as well. Previously imported user packages remain in `sys.modules`, and their `__file__`, `__path__`, or `__spec__` can still point to the removed dependency directory. Adding the new directory to `sys.path` does not refresh those existing modules. As a result, resumed actions can fail when they access package resources, for example through `Skills.from_package(...)` or `importlib.resources`, even though the resource exists in the newly distributed package. Repeated recovery attempts may then fail for the same reason. The root cause is a lifecycle mismatch: Flink replaces and deletes task-attempt dependency directories, while Flink Agents does not refresh the shared Python import state before loading user actions and resources in the new dependency generation. ### How to reproduce 1. Run a Flink Agents job with a Python action whose package also contains a resource such as `skills/<name>/SKILL.md`. 2. Let the task import that package from the initial `python-dist-*` directory. 3. Trigger a regional failover while keeping the TaskManager JVM alive, so the old dependency directory is released and the recovered attempt receives a new one. 4. Resume the action and load the packaged resource. 5. Observe that the cached package path still references the deleted directory and resource loading fails. A deterministic reduced reproduction is to import a package from generation A, delete generation A, create generation B with the same module name, prepend B to `sys.path`, and access the package resource. The existing module continues to use generation A unless the job-owned module and importer caches are refreshed. ### Version and environment - Flink Agents: release-0.3 (the same lifecycle is present on current `main`) - Flink: 2.2 - Java: 11 - Python: 3.10/3.11 - Pemja execution type: `MULTI_THREAD` - Deployment: TaskManager JVM remains alive across regional task failover ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
