Skip to content

fix(parquet/pqarrow): release temporary extension arrays - #1060

Open
fallintoplace wants to merge 3 commits into
apache:mainfrom
fallintoplace:fix/pqarrow-extension-array-release
Open

fix(parquet/pqarrow): release temporary extension arrays#1060
fallintoplace wants to merge 3 commits into
apache:mainfrom
fallintoplace:fix/pqarrow-extension-array-release

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

extensionReader.BuildArray creates extension arrays and passes them to arrow.NewChunked, which retains each chunk. The original references were not released, leaking one array reference per output chunk. A failure after some chunks have already been wrapped also leaked those partial results.

What changes are included in this PR?

Defer cleanup of every constructed extension array. On success, arrow.NewChunked keeps its retained references; on failure, already-constructed chunks are released during unwinding.

Are these changes tested?

Yes. A checked-allocator regression test makes the second extension chunk fail after the first has been wrapped. Reverting the cleanup leaves the first chunk's buffers allocated; the fix returns allocator usage to zero.

go test ./parquet/pqarrow -run TestExtensionReaderBuildArrayReleasesPartialChunksOnPanic

Are there any user-facing changes?

No API changes. Extension-column reads no longer retain temporary or partially constructed array references.

@fallintoplace
fallintoplace requested a review from zeroshade as a code owner July 29, 2026 16:54
extType := er.fieldWithExt.Type.(arrow.ExtensionType)

newChunks := make([]arrow.Array, len(chkd.Chunks()))
defer func() {

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.

Can we add a unit test to repro this using the checked allocator?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants