You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "qiuyanjun888 (via GitHub)" <gi...@apache.org> on 2026/06/22 13:01:36 UTC
[PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
qiuyanjun888 opened a new pull request, #28503:
URL: https://github.com/apache/flink/pull/28503
## What is the purpose of the change
This PR fixes FLINK-39215, where `PythonDriver` could leave behind a generated `pyflink/<uuid>` temporary directory if `PythonEnvUtils.launchPy4jPythonClient(...)` failed after preparing the Python environment but before returning the Python process.
Root cause: `PythonDriver` created the shutdown hook only after `launchPy4jPythonClient(...)` returned successfully. When `preparePythonEnvironment(...)` had already populated the temporary directory and `startPythonProcess(...)` then failed, no shutdown hook existed to clean up that directory.
## Brief change log
- Keep the generated `tmpDir` and Python process reference visible to the failure path in `PythonDriver`.
- Clean up the generated temporary directory and gateway when Python client launch fails before the normal shutdown hook is registered.
- Add a focused `PythonDriverTest` regression test that triggers a Python client launch failure with an invalid `-pyclientexec` and verifies that no per-run `pyflink` tmp directory remains.
## Verifying this change
This change added tests and can be verified as follows:
- Added `PythonDriverTest#testCleanupTmpDirWhenPythonClientLaunchFails`.
- Verified the new regression test failed before the production fix because a `pyflink/<uuid>` temporary directory was left behind.
- Verified the focused regression test after the fix:
- `./mvnw -pl flink-python -Dtest=PythonDriverTest#testCleanupTmpDirWhenPythonClientLaunchFails test -DskipITs -Drat.skip=true -Dcheckstyle.skip=true`
- Verified the full `PythonDriverTest` class:
- `./mvnw -pl flink-python -Dtest=PythonDriverTest test -DskipITs -Drat.skip=true -Dcheckstyle.skip=true`
- Verified related Python client process tests with a temporary `python -> python3` symlink because this environment does not provide a `python` command by default:
- `./mvnw -pl flink-python -Dtest=PythonDriverTest,PythonEnvUtilsTest test -DskipITs -Drat.skip=true -Dcheckstyle.skip=true`
- Verified `git diff --check`.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes: Hermes Agent (OpenAI GPT-5.5)
Generated-by: Hermes Agent (OpenAI GPT-5.5)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
Posted by "qiuyanjun888 (via GitHub)" <gi...@apache.org>.
qiuyanjun888 commented on PR #28503:
URL: https://github.com/apache/flink/pull/28503#issuecomment-4805927656
This PR is focused on PyFlink PythonDriver temporary directory cleanup.
@dianfu @twalthr could you please take a look when you have time and advise whether this approach is acceptable for this area and can move forward?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
Posted by "qiuyanjun888 (via GitHub)" <gi...@apache.org>.
qiuyanjun888 commented on PR #28503:
URL: https://github.com/apache/flink/pull/28503#issuecomment-4910272054
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28503:
URL: https://github.com/apache/flink/pull/28503#issuecomment-4768659556
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "1257a625b5c7147f3f1c449a3ddbd15417388844",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "1257a625b5c7147f3f1c449a3ddbd15417388844",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 1257a625b5c7147f3f1c449a3ddbd15417388844 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
Posted by "qiuyanjun888 (via GitHub)" <gi...@apache.org>.
qiuyanjun888 closed pull request #28503: [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure
URL: https://github.com/apache/flink/pull/28503
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
Posted by "dianfu (via GitHub)" <gi...@apache.org>.
dianfu commented on PR #28503:
URL: https://github.com/apache/flink/pull/28503#issuecomment-5140232805
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39215] [python] Clean up PythonDriver tmp dir on launch failure [flink]
Posted by "dianfu (via GitHub)" <gi...@apache.org>.
dianfu commented on PR #28503:
URL: https://github.com/apache/flink/pull/28503#issuecomment-5089825512
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org