Skip to content

fix(arrow/csv): release Reader record builders - #1059

Open
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/csv-reader-builder-release
Open

fix(arrow/csv): release Reader record builders#1059
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/csv-reader-builder-release

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Every CSV reader owns a RecordBuilder, but final Reader.Release did not release it. Header processing with an explicit schema also replaced the initial builder without releasing it, leaking two builders on that path.

What changes are included in this PR?

Release the old builder before header-driven replacement, and release the active builder when the reader reference count reaches zero.

Are these changes tested?

Yes. The regression test uses a supported custom extension builder that reserves allocator-backed storage when constructed and counts releases. It covers explicit-schema readers with and without headers, proving that one builder is released on the direct path and both builders are released on the header-replacement path.

go test ./arrow/csv -run TestReaderReleaseFreesRecordBuilders

Are there any user-facing changes?

No API changes. Releasing a CSV reader now frees every builder it owns.

@fallintoplace
fallintoplace requested a review from zeroshade as a code owner July 29, 2026 16:54
@fallintoplace fallintoplace changed the title fix(arrow/csv): release record builders when Reader is released fix(arrow/csv): release Reader record builders Jul 29, 2026
Comment thread arrow/csv/reader_test.go Outdated
}
}

func TestReaderReleaseFreesRecordBuilder(t *testing.T) {

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.

I reverted your changes and ran the test on top of main. It passes without reproducing any bug.

Image

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