-
Notifications
You must be signed in to change notification settings - Fork 1.6k
GH-3558: Properly close buffers #3559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Fokko
wants to merge
17
commits into
apache:master
Choose a base branch
from
Fokko:fd-correctly-close-buffers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+74
−11
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a494af3
GH-3558: Properly close buffers
Fokko d1a7cec
Track the buffers and close all the resources in tests
Fokko 00931ba
Disable verification for now
Fokko e4dc4fc
Merge branch 'fd-correctly-close-buffers' of github.com:Fokko/parquet…
Fokko ca0ce18
Reduce changes
Fokko 0ec9fde
Merge branch 'master' into fd-correctly-close-buffers
Fokko a470682
Merge branch 'master' of github.com:apache/parquet-java into fd-corre…
Fokko c6e92d1
Merge branch 'fd-correctly-close-buffers' of github.com:Fokko/parquet…
Fokko ffd978e
Spotless
Fokko 81297e1
Revert some unrelated changes
Fokko 6a2fe5e
Thanks Gang
Fokko 4b45d07
Merge branch 'master' into fd-correctly-close-buffers
Fokko 8fc07d2
Merge branch 'master' of github.com:apache/parquet-java into fd-corre…
Fokko 4fbc84e
Revert "Thanks Gang"
Fokko e1edc2d
Release in try-catch
Fokko cb6d8f5
Fix failing test
Fokko 28778e6
Revert unrelated changes
Fokko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1190,10 +1190,18 @@ private ColumnChunkPageReadStore internalReadRowGroup(int blockIndex) throws IOE | |
| } | ||
| // actually read all the chunks | ||
| ChunkListBuilder builder = new ChunkListBuilder(block.getRowCount()); | ||
| readAllPartsVectoredOrNormal(allParts, builder); | ||
| rowGroup.setReleaser(builder.releaser); | ||
| for (Chunk chunk : builder.build()) { | ||
| readChunkPages(chunk, block, rowGroup); | ||
| try { | ||
| readAllPartsVectoredOrNormal(allParts, builder); | ||
| rowGroup.setReleaser(builder.releaser); | ||
| for (Chunk chunk : builder.build()) { | ||
| readChunkPages(chunk, block, rowGroup); | ||
| } | ||
| } catch (RuntimeException | IOException e) { | ||
| // If we fail before the releaser is transferred to the row group (e.g. a vectored range | ||
| // times out after earlier ranges already registered their buffers), release any buffers | ||
| // that were registered so far so that partially-read row groups do not leak. | ||
| builder.releaser.close(); | ||
| throw e; | ||
| } | ||
|
|
||
| return rowGroup; | ||
|
|
@@ -1464,10 +1472,18 @@ private ColumnChunkPageReadStore internalReadFilteredRowGroup( | |
| } | ||
| } | ||
| } | ||
| readAllPartsVectoredOrNormal(allParts, builder); | ||
| rowGroup.setReleaser(builder.releaser); | ||
| for (Chunk chunk : builder.build()) { | ||
| readChunkPages(chunk, block, rowGroup); | ||
| try { | ||
| readAllPartsVectoredOrNormal(allParts, builder); | ||
| rowGroup.setReleaser(builder.releaser); | ||
| for (Chunk chunk : builder.build()) { | ||
| readChunkPages(chunk, block, rowGroup); | ||
| } | ||
| } catch (RuntimeException | IOException e) { | ||
| // If we fail before the releaser is transferred to the row group (e.g. a vectored range | ||
| // times out after earlier ranges already registered their buffers), release any buffers | ||
| // that were registered so far so that partially-read row groups do not leak. | ||
| builder.releaser.close(); | ||
| throw e; | ||
| } | ||
|
|
||
| return rowGroup; | ||
|
|
@@ -2368,6 +2384,10 @@ public void readFromVectoredRange(ParquetFileRange currRange, ChunkListBuilder b | |
| LOG.error(error, e); | ||
| throw new IOException(error, e); | ||
| } | ||
| // Release the vectored-read buffer back to the allocator when the row group is closed. | ||
| // Requires fs.file.checksum.verify=false so the returned buffer is the allocator buffer | ||
| // rather than a sliced subset (see Hadoop's fs.file.checksum.verify docs). | ||
| builder.addBuffersToRelease(Collections.singletonList(buffer)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please register the buffer immediately after |
||
| ByteBufferInputStream stream = ByteBufferInputStream.wrap(buffer); | ||
| for (ChunkDescriptor descriptor : chunks) { | ||
| builder.add(descriptor, stream.sliceBuffers(descriptor.size), f); | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
| <configuration> | ||
| <property> | ||
| <name>fs.file.checksum.verify</name> | ||
| <value>false</value> | ||
| <description> | ||
| Disable checksum verification on the local file system used by tests. | ||
| Hadoop's ChecksumFileSystem.readVectored allocates checksum buffers via | ||
| the caller-supplied ByteBufferAllocator without releasing them; the | ||
| leaked buffers trip TrackingByteBufferAllocator leak detection in tests. | ||
| Turning off checksum verification skips the checksum read path entirely | ||
| and avoids the leak. | ||
| </description> | ||
| </property> | ||
| </configuration> |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With checksum verification enabled by default,
ChecksumFileSystemreturns a sliced buffer rather than the allocator-owned buffer. Releasing it here fails with strict allocators and leaves the original allocations unreleased;core-site.xmlonly hides this path in tests. Please either fall back whenVECTOREDIO_BUFFERS_SLICEDis advertised or track and release the actual allocated buffers.