HDFS-17902. StripedBlockChecksumReconstructor leaks connections on init failure#8393
Open
CapMoon wants to merge 2 commits intoapache:trunkfrom
Open
HDFS-17902. StripedBlockChecksumReconstructor leaks connections on init failure#8393CapMoon wants to merge 2 commits intoapache:trunkfrom
CapMoon wants to merge 2 commits intoapache:trunkfrom
Conversation
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
HDFS-17902. StripedBlockChecksumReconstructor leaks connections on init failure
Description of PR
When BlockGroupNonStripedChecksumComputer.recalculateChecksum() allocates a StripedBlockChecksumReconstructor with try-with-resources, the reconstructor's constructor calls StripedReconstructor's superclass constructor first, which creates a StripedReader. The constructor then calls getStripedReader().init(), which in turn calls initReaders().
If initReaders() fails because nSuccess < minRequiredSources, it throws IOException. initReaders() does not close StripedBlockReader instances that were already created and may already hold open block/TCP connections to peer DataNodes.
Because the constructor throws before the StripedBlockChecksumReconstructor instance is successfully created, the try-with-resources statement never assigns the resource variable and therefore does not invoke Closeable.close() on the reconstructor (JLS: resource is only closed if initialization completes normally). As a result, StripedReader.close() is never called on that code path, and connections opened during the failed initReaders() loop can leak.
By contrast, StripedBlockReconstructor.run() always calls getStripedReader().close() in a finally block, so the same failure mode is cleaned up there.