From f23fd7208bbe4c435d02bccfa21710e579f793e4 Mon Sep 17 00:00:00 2001 From: Vasudevan Date: Mon, 15 Jan 2018 22:15:01 +0530 Subject: [PATCH] HBASE-19732 Replica regions does not return back the MSLAB chunks to pool (Ram) --- .../org/apache/hadoop/hbase/regionserver/HStore.java | 1 + .../hadoop/hbase/regionserver/MemStoreSnapshot.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index 2ccc8a01645..01121dd80e8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -2283,6 +2283,7 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat long snapshotId = -1; // -1 means do not drop if (dropMemstoreSnapshot && snapshot != null) { snapshotId = snapshot.getId(); + snapshot.close(); } HStore.this.updateStorefiles(storeFiles, snapshotId); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreSnapshot.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreSnapshot.java index 0d4e5f15dbb..1a0317d9cbf 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreSnapshot.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreSnapshot.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.regionserver; import org.apache.yetus.audience.InterfaceAudience; +import java.io.Closeable; import java.util.List; /** * Holds details of the snapshot taken on a MemStore. Details include the snapshot's identifier, @@ -26,7 +27,7 @@ import java.util.List; * all the cells and a scanner to read all cells in it. */ @InterfaceAudience.Private -public class MemStoreSnapshot { +public class MemStoreSnapshot implements Closeable { private final long id; private final int cellsCount; private final long dataSize; @@ -90,4 +91,13 @@ public class MemStoreSnapshot { public boolean isTagsPresent() { return this.tagsPresent; } + + @Override + public void close() { + if (this.scanners != null) { + for (KeyValueScanner scanner : scanners) { + scanner.close(); + } + } + } }