Skip to content

fix(arrow/array): always release JSON reader builder - #1065

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

fix(arrow/array): always release JSON reader builder#1065
fallintoplace wants to merge 4 commits into
apache:mainfrom
fallintoplace:fix/json-reader-release-builder

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What changed

Release the JSON reader record builder whenever the final reader reference is released, independently of whether a current record batch exists.

Why

The builder release was nested under the current-record check. A decode error can leave cur nil while the builder still owns buffers from values parsed before the error, so releasing the reader did not free those buffers.

The regression test parses an object far enough to allocate builder storage, triggers a duplicate-key error before a record batch is produced, and verifies with a checked allocator that Release frees the partial builder state.

Testing

  • go test ./arrow/array
  • go test -race ./arrow/array -run TestJSONReaderReleaseBuilderAfterPartialReadError

@fallintoplace
fallintoplace requested a review from zeroshade as a code owner July 29, 2026 21:58
Comment thread arrow/array/json_reader_test.go Outdated
assert.False(t, rdr.Next())
}

func TestJSONReaderReleaseBuilder(t *testing.T) {

@serramatutu serramatutu Jul 30, 2026

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 change to json_reader.go and ran the test you introduced. The test did not break, i.e it does not reproduce any memory leak.

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