Skip to content

GH-55695: [GLib][Ruby] Close the opened file in gparquet_arrow_file_reader_close() - #55703

Open
kou wants to merge 1 commit into
apache:mainfrom
kou:gh-55695-parquet-glib-close
Open

kou wants to merge 1 commit into
apache:mainfrom
kou:gh-55695-parquet-glib-close

Conversation

@kou

@kou kou commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

gparquet_arrow_file_reader_new_path() and
gparquet_arrow_file_reader_new_path_full() open the given path as a memory mapped file. But gparquet_arrow_file_reader_close() doesn't close it because parquet::ParquetFileReader::Close() doesn't close its source. So the file is kept open until the reader is GC-ed. We can't remove the file on Windows while it's open. This is why TestBooleanStatistics in Red Parquet fails randomly on Windows: it depends on GC.start freeing the reader.

What changes are included in this PR?

gparquet_arrow_file_reader_close() closes the file opened by the reader now. The source passed to gparquet_arrow_file_reader_new_arrow() and gparquet_arrow_file_reader_new_arrow_full() isn't closed because it's owned by the caller.

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Closing the reader after default pre-buffered reads leaves cached mapped buffers that can block file deletion on Windows, requiring cache release during close and a regression test that deletes the file before reader destruction.

1 open issue
What changed in this PR

This PR addresses GH-55695’s intermittent Windows file-deletion failures by making GLib Parquet readers explicitly close files they open, rather than relying on garbage collection.

Changes:

  • Track and close reader-owned sources while leaving caller-supplied streams open.
  • Add close-behavior tests and explicit reader cleanup.
  • Remove forced garbage collection from Ruby boolean-statistics tests.
File Description
ruby/​red-parquet/​test/​test-boolean-statistics.rb Remove statistics clearing and forced garbage collection.
c_glib/​test/​parquet/​test-arrow-file-reader.rb Centralize reader cleanup and test source ownership on close.
c_glib/​parquet-glib/​arrow-file-reader.cpp Track owned sources, close them explicitly, and document ownership behavior.

Review effort: Balanced

…file_reader_close()

gparquet_arrow_file_reader_new_path() and
gparquet_arrow_file_reader_new_path_full() open the given path as a
memory mapped file. But gparquet_arrow_file_reader_close() doesn't
close it because parquet::ParquetFileReader::Close() doesn't close
its source. So the file is kept open until the reader is GC-ed. We
can't remove the file on Windows while it's open. This is why
TestBooleanStatistics in Red Parquet fails randomly on Windows: it
depends on GC.start freeing the reader.

gparquet_arrow_file_reader_close() closes the file opened by the
reader now. The source passed to gparquet_arrow_file_reader_new_arrow()
and gparquet_arrow_file_reader_new_arrow_full() isn't closed because
it's owned by the caller.

Tests don't depend on GC to remove temporary files now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kou
kou force-pushed the gh-55695-parquet-glib-close branch from 83603a5 to 00c95ba Compare November 22, 2026 13:28
Copilot AI balanced review requested due to automatic review settings November 22, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the reader-owned source cleanup change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants