[python] Clean up normal files when composite writer metadata creation fails - #9917
Merged
JingsongLi merged 1 commit intoSep 17, 2026
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The implementation directly addresses the reported leak and includes focused regression coverage.
Pull request overview
Adds cleanup for normal data files when composite writer metadata creation fails.
Changes:
- Wraps normal-file writing and metadata creation in cleanup handlers.
- Adds regression coverage for both composite writers.
File summaries
| File | Description |
|---|---|
dedicated_format_writer.py |
Deletes failed normal-file output and re-raises errors. |
data_vector_writer.py |
Adds equivalent cleanup handling. |
writer_file_cleanup_test.py |
Verifies failed metadata creation leaves no Parquet file. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
JingsongLi
reviewed
Sep 17, 2026
JingsongLi
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the normal-file cleanup path. Deleting the completed data file when subsequent metadata creation fails prevents orphan files while preserving the original exception; the regression coverage exercises both composite writers. No additional blocking issues found.
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fixes #9916
DataVectorWriterandDedicatedFormatWritercan leave a normal data file behind if writing succeeds but a later step, such as reading the file size, fails before returning its metadata.Wrap normal-file output and metadata creation in
try/except. On failure, calldelete_quietlyfor the current file and re-raise the original exception.Tests
Add one regression test covering both writers: write a real Parquet file, fail while reading its size, and assert that no Parquet file remains. Both cases fail on the base revision and pass with the fix.
The new regression and existing composite flush/shared-shredding tests passed (10 test methods). Flake8 and whitespace checks passed with Python 3.12.6 / PyArrow 19.0.1.