You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ss...@apache.org on 2017/09/27 18:40:00 UTC
[1/4] phoenix git commit: PHOENIX-4225 Using Google cache may lead to
lock up on RS side.
Repository: phoenix
Updated Branches:
refs/heads/4.x-HBase-0.98 f8df68997 -> ca664fe10
refs/heads/4.x-HBase-1.1 fd2b064a0 -> 4e51fe772
refs/heads/4.x-HBase-1.2 6f923a419 -> d714afcec
refs/heads/master 84dc1d44a -> 764eb8f13
PHOENIX-4225 Using Google cache may lead to lock up on RS side.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/764eb8f1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/764eb8f1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/764eb8f1
Branch: refs/heads/master
Commit: 764eb8f13237a89961e259aca366e45b38b76ef1
Parents: 84dc1d4
Author: Sergey Soldatov <ss...@apache.org>
Authored: Tue Sep 26 14:41:53 2017 -0700
Committer: Sergey Soldatov <ss...@apache.org>
Committed: Wed Sep 27 10:42:59 2017 -0700
----------------------------------------------------------------------
.../apache/phoenix/cache/TenantCacheImpl.java | 2 ++
.../apache/phoenix/cache/TenantCacheTest.java | 37 +++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/764eb8f1/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
index 3d178f6..fdf0646 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
@@ -100,11 +100,13 @@ public class TenantCacheImpl implements TenantCache {
@Override
public Closeable getServerCache(ImmutableBytesPtr cacheId) {
+ getServerCaches().cleanUp();
return getServerCaches().getIfPresent(cacheId);
}
@Override
public Closeable addServerCache(ImmutableBytesPtr cacheId, ImmutableBytesWritable cachePtr, byte[] txState, ServerCacheFactory cacheFactory, boolean useProtoForIndexMaintainer) throws SQLException {
+ getServerCaches().cleanUp();
MemoryChunk chunk = this.getMemoryManager().allocate(cachePtr.getLength() + txState.length);
boolean success = false;
try {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/764eb8f1/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
index 932149c..f4c83b2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.cache;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.io.Closeable;
import java.io.DataInput;
@@ -67,7 +68,41 @@ public class TenantCacheTest {
cache.cleanUp();
assertEquals(maxBytes, memoryManager.getAvailableMemory());
}
-
+
+
+ @Test
+ public void testFreeMemoryOnAccess() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 1000;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("a"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(maxBytes-1, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ assertNull(cache.getServerCache(cacheId1));
+ assertEquals(maxBytes, memoryManager.getAvailableMemory());
+ }
+
+ @Test
+ public void testExpiredCacheOnAddingNew() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 10;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesPtr cacheId2 = new ImmutableBytesPtr(Bytes.toBytes("b"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("12345678"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ }
+
public static class ManualTicker extends Ticker {
public long time = 0;
[3/4] phoenix git commit: PHOENIX-4225 Using Google cache may lead to
lock up on RS side.
Posted by ss...@apache.org.
PHOENIX-4225 Using Google cache may lead to lock up on RS side.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d714afce
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d714afce
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d714afce
Branch: refs/heads/4.x-HBase-1.2
Commit: d714afcecfa44e9ce4b017e9c15ecd4cd0d4ba51
Parents: 6f923a4
Author: Sergey Soldatov <ss...@apache.org>
Authored: Tue Sep 26 14:41:53 2017 -0700
Committer: Sergey Soldatov <ss...@apache.org>
Committed: Wed Sep 27 10:43:41 2017 -0700
----------------------------------------------------------------------
.../apache/phoenix/cache/TenantCacheImpl.java | 2 ++
.../apache/phoenix/cache/TenantCacheTest.java | 37 +++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/d714afce/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
index 3d178f6..fdf0646 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
@@ -100,11 +100,13 @@ public class TenantCacheImpl implements TenantCache {
@Override
public Closeable getServerCache(ImmutableBytesPtr cacheId) {
+ getServerCaches().cleanUp();
return getServerCaches().getIfPresent(cacheId);
}
@Override
public Closeable addServerCache(ImmutableBytesPtr cacheId, ImmutableBytesWritable cachePtr, byte[] txState, ServerCacheFactory cacheFactory, boolean useProtoForIndexMaintainer) throws SQLException {
+ getServerCaches().cleanUp();
MemoryChunk chunk = this.getMemoryManager().allocate(cachePtr.getLength() + txState.length);
boolean success = false;
try {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/d714afce/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
index 932149c..f4c83b2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.cache;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.io.Closeable;
import java.io.DataInput;
@@ -67,7 +68,41 @@ public class TenantCacheTest {
cache.cleanUp();
assertEquals(maxBytes, memoryManager.getAvailableMemory());
}
-
+
+
+ @Test
+ public void testFreeMemoryOnAccess() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 1000;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("a"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(maxBytes-1, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ assertNull(cache.getServerCache(cacheId1));
+ assertEquals(maxBytes, memoryManager.getAvailableMemory());
+ }
+
+ @Test
+ public void testExpiredCacheOnAddingNew() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 10;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesPtr cacheId2 = new ImmutableBytesPtr(Bytes.toBytes("b"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("12345678"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ }
+
public static class ManualTicker extends Ticker {
public long time = 0;
[4/4] phoenix git commit: PHOENIX-4225 Using Google cache may lead to
lock up on RS side.
Posted by ss...@apache.org.
PHOENIX-4225 Using Google cache may lead to lock up on RS side.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ca664fe1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ca664fe1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ca664fe1
Branch: refs/heads/4.x-HBase-0.98
Commit: ca664fe1020166d5b074276117a71bb2769edd1d
Parents: f8df689
Author: Sergey Soldatov <ss...@apache.org>
Authored: Tue Sep 26 14:41:53 2017 -0700
Committer: Sergey Soldatov <ss...@apache.org>
Committed: Wed Sep 27 10:44:37 2017 -0700
----------------------------------------------------------------------
.../apache/phoenix/cache/TenantCacheImpl.java | 2 ++
.../apache/phoenix/cache/TenantCacheTest.java | 37 +++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca664fe1/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
index 3d178f6..fdf0646 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
@@ -100,11 +100,13 @@ public class TenantCacheImpl implements TenantCache {
@Override
public Closeable getServerCache(ImmutableBytesPtr cacheId) {
+ getServerCaches().cleanUp();
return getServerCaches().getIfPresent(cacheId);
}
@Override
public Closeable addServerCache(ImmutableBytesPtr cacheId, ImmutableBytesWritable cachePtr, byte[] txState, ServerCacheFactory cacheFactory, boolean useProtoForIndexMaintainer) throws SQLException {
+ getServerCaches().cleanUp();
MemoryChunk chunk = this.getMemoryManager().allocate(cachePtr.getLength() + txState.length);
boolean success = false;
try {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca664fe1/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
index 932149c..f4c83b2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.cache;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.io.Closeable;
import java.io.DataInput;
@@ -67,7 +68,41 @@ public class TenantCacheTest {
cache.cleanUp();
assertEquals(maxBytes, memoryManager.getAvailableMemory());
}
-
+
+
+ @Test
+ public void testFreeMemoryOnAccess() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 1000;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("a"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(maxBytes-1, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ assertNull(cache.getServerCache(cacheId1));
+ assertEquals(maxBytes, memoryManager.getAvailableMemory());
+ }
+
+ @Test
+ public void testExpiredCacheOnAddingNew() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 10;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesPtr cacheId2 = new ImmutableBytesPtr(Bytes.toBytes("b"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("12345678"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ }
+
public static class ManualTicker extends Ticker {
public long time = 0;
[2/4] phoenix git commit: PHOENIX-4225 Using Google cache may lead to
lock up on RS side.
Posted by ss...@apache.org.
PHOENIX-4225 Using Google cache may lead to lock up on RS side.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/4e51fe77
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4e51fe77
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4e51fe77
Branch: refs/heads/4.x-HBase-1.1
Commit: 4e51fe7726b896b5c05e43aee825cfb1aded480d
Parents: fd2b064
Author: Sergey Soldatov <ss...@apache.org>
Authored: Tue Sep 26 14:41:53 2017 -0700
Committer: Sergey Soldatov <ss...@apache.org>
Committed: Wed Sep 27 10:43:34 2017 -0700
----------------------------------------------------------------------
.../apache/phoenix/cache/TenantCacheImpl.java | 2 ++
.../apache/phoenix/cache/TenantCacheTest.java | 37 +++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/4e51fe77/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
index 3d178f6..fdf0646 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java
@@ -100,11 +100,13 @@ public class TenantCacheImpl implements TenantCache {
@Override
public Closeable getServerCache(ImmutableBytesPtr cacheId) {
+ getServerCaches().cleanUp();
return getServerCaches().getIfPresent(cacheId);
}
@Override
public Closeable addServerCache(ImmutableBytesPtr cacheId, ImmutableBytesWritable cachePtr, byte[] txState, ServerCacheFactory cacheFactory, boolean useProtoForIndexMaintainer) throws SQLException {
+ getServerCaches().cleanUp();
MemoryChunk chunk = this.getMemoryManager().allocate(cachePtr.getLength() + txState.length);
boolean success = false;
try {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/4e51fe77/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
index 932149c..f4c83b2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/cache/TenantCacheTest.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.cache;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.io.Closeable;
import java.io.DataInput;
@@ -67,7 +68,41 @@ public class TenantCacheTest {
cache.cleanUp();
assertEquals(maxBytes, memoryManager.getAvailableMemory());
}
-
+
+
+ @Test
+ public void testFreeMemoryOnAccess() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 1000;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("a"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(maxBytes-1, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ assertNull(cache.getServerCache(cacheId1));
+ assertEquals(maxBytes, memoryManager.getAvailableMemory());
+ }
+
+ @Test
+ public void testExpiredCacheOnAddingNew() throws Exception {
+ int maxServerCacheTimeToLive = 10;
+ long maxBytes = 10;
+ GlobalMemoryManager memoryManager = new GlobalMemoryManager(maxBytes);
+ ManualTicker ticker = new ManualTicker();
+ TenantCacheImpl cache = new TenantCacheImpl(memoryManager, maxServerCacheTimeToLive, ticker);
+ ImmutableBytesPtr cacheId1 = new ImmutableBytesPtr(Bytes.toBytes("a"));
+ ImmutableBytesPtr cacheId2 = new ImmutableBytesPtr(Bytes.toBytes("b"));
+ ImmutableBytesWritable cachePtr = new ImmutableBytesWritable(Bytes.toBytes("12345678"));
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ ticker.time += (maxServerCacheTimeToLive + 1) * 1000000;
+ cache.addServerCache(cacheId1, cachePtr, ByteUtil.EMPTY_BYTE_ARRAY, cacheFactory, true);
+ assertEquals(2, memoryManager.getAvailableMemory());
+ }
+
public static class ManualTicker extends Ticker {
public long time = 0;