You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ad...@apache.org on 2022/08/19 16:47:52 UTC
[ozone] branch master updated: HDDS-7136. Memory leak due to ChunkInputStream.close() not releasing buffer (#3692)
This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 01afc1ff33 HDDS-7136. Memory leak due to ChunkInputStream.close() not releasing buffer (#3692)
01afc1ff33 is described below
commit 01afc1ff33a5728aaca2aaebff3683bc59f721e6
Author: Doroszlai, Attila <64...@users.noreply.github.com>
AuthorDate: Fri Aug 19 18:47:48 2022 +0200
HDDS-7136. Memory leak due to ChunkInputStream.close() not releasing buffer (#3692)
---
.../hadoop/hdds/scm/storage/ChunkInputStream.java | 1 +
.../ozone/client/rpc/read/TestChunkInputStream.java | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
index f22e706580..2a22c2293f 100644
--- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
+++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/ChunkInputStream.java
@@ -282,6 +282,7 @@ public class ChunkInputStream extends InputStream
@Override
public synchronized void close() {
+ releaseBuffers();
releaseClient();
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestChunkInputStream.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestChunkInputStream.java
index 82f494ffd6..c9a9c6f2b5 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestChunkInputStream.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestChunkInputStream.java
@@ -44,6 +44,7 @@ public class TestChunkInputStream extends TestInputStreamBase {
public void testAll() throws Exception {
testChunkReadBuffers();
testBufferRelease();
+ testCloseReleasesBuffers();
}
@@ -112,6 +113,25 @@ public class TestChunkInputStream extends TestInputStreamBase {
"reaching EOF.", chunk0Stream.getCachedBuffers());
}
+ private void testCloseReleasesBuffers() throws Exception {
+ String keyName = getNewKeyName();
+ writeRandomBytes(keyName, CHUNK_SIZE);
+
+ try (KeyInputStream keyInputStream = getKeyInputStream(keyName)) {
+ BlockInputStream block0Stream =
+ (BlockInputStream) keyInputStream.getBlockStreams().get(0);
+ block0Stream.initialize();
+
+ ChunkInputStream chunk0Stream = block0Stream.getChunkStreams().get(0);
+ readDataFromChunk(chunk0Stream, 0, 1);
+ Assert.assertNotNull(chunk0Stream.getCachedBuffers());
+
+ chunk0Stream.close();
+
+ Assert.assertNull(chunk0Stream.getCachedBuffers());
+ }
+ }
+
/**
* Test that ChunkInputStream buffers are released as soon as the last byte
* of the buffer is read.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org