You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ch...@apache.org on 2020/01/06 22:17:50 UTC
[phoenix] branch 4.15-HBase-1.4 updated: PHOENIX-5655 : ServerCache
client should remove cache map entry correctly
This is an automated email from the ASF dual-hosted git repository.
chinmayskulkarni pushed a commit to branch 4.15-HBase-1.4
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.15-HBase-1.4 by this push:
new 09b0476 PHOENIX-5655 : ServerCache client should remove cache map entry correctly
09b0476 is described below
commit 09b0476ca5595695bd761b0451d65732c301d338
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Sat Jan 4 12:14:32 2020 +0530
PHOENIX-5655 : ServerCache client should remove cache map entry correctly
Signed-off-by: Chinmay Kulkarni <ch...@apache.org>
---
.../phoenix/end2end/join/HashJoinCacheIT.java | 102 +++++++++++++++++----
.../apache/phoenix/cache/ServerCacheClient.java | 2 +-
2 files changed, 87 insertions(+), 17 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinCacheIT.java
index d2414c6..559cff6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinCacheIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/HashJoinCacheIT.java
@@ -20,7 +20,6 @@ package org.apache.phoenix.end2end.join;
import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import static org.junit.Assert.fail;
-import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@@ -58,24 +57,34 @@ public class HashJoinCacheIT extends BaseJoinIT {
TestUtil.addCoprocessor(conn, SchemaUtil.normalizeFullTableName(realName), InvalidateHashCache.class);
return realName;
}
-
- @Test
+
+ @Test(expected = HashJoinCacheNotFoundException.class)
public void testExpiredCache() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
props.setProperty(QueryServices.MAX_SERVER_CACHE_TIME_TO_LIVE_MS_ATTRIB, "1");
- Connection conn = DriverManager.getConnection(getUrl(), props);
- String tableName1 = getTableName(conn, JOIN_SUPPLIER_TABLE_FULL_NAME);
- String tableName2 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME);
- String query = "SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " +
- tableName1 + " supp RIGHT JOIN " + tableName2 +
- " item ON item.\"supplier_id\" = supp.\"supplier_id\" ORDER BY \"item_id\"";
- try {
- PreparedStatement statement = conn.prepareStatement(query);
- ResultSet rs = statement.executeQuery();
+ PreparedStatement statement = null;
+ ResultSet rs = null;
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ String tableName1 = getTableName(conn, JOIN_SUPPLIER_TABLE_FULL_NAME);
+ String tableName2 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME);
+ String query =
+ "SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM "
+ + tableName1
+ + " supp RIGHT JOIN "
+ + tableName2
+ + " item ON item.\"supplier_id\" = supp.\"supplier_id\" ORDER BY \"item_id\"";
+ statement = conn.prepareStatement(query);
+ rs = statement.executeQuery();
rs.next();
+ // should not reach here
fail("HashJoinCacheNotFoundException was not thrown or incorrectly handled");
- } catch (HashJoinCacheNotFoundException e) {
- //Expected exception
+ } finally {
+ if (statement != null) {
+ statement.close();
+ }
+ if (rs != null) {
+ rs.close();
+ }
}
}
@@ -83,8 +92,8 @@ public class HashJoinCacheIT extends BaseJoinIT {
public static Random rand= new Random();
public static List<ImmutableBytesPtr> lastRemovedJoinIds=new ArrayList<ImmutableBytesPtr>();
@Override
- public RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c, final Scan scan,
- final RegionScanner s) throws IOException {
+ public RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
+ final Scan scan, final RegionScanner s) {
final HashJoinInfo joinInfo = HashJoinInfo.deserializeHashJoinFromScan(scan);
if (joinInfo != null) {
TenantCache cache = GlobalCache.getTenantCache(c.getEnvironment(), null);
@@ -101,4 +110,65 @@ public class HashJoinCacheIT extends BaseJoinIT {
}
}
+
+ @Test(expected = HashJoinCacheNotFoundException.class)
+ public void testExpiredCacheWithLeftJoin() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ props.setProperty(QueryServices.MAX_SERVER_CACHE_TIME_TO_LIVE_MS_ATTRIB, "1");
+ PreparedStatement statement = null;
+ ResultSet rs = null;
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ String tableName1 = getTableName(conn, JOIN_SUPPLIER_TABLE_FULL_NAME);
+ String tableName2 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME);
+ final String query =
+ "SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM "
+ + tableName1
+ + " supp LEFT JOIN "
+ + tableName2
+ + " item ON item.\"supplier_id\" = supp.\"supplier_id\" ORDER BY \"item_id\"";
+ statement = conn.prepareStatement(query);
+ rs = statement.executeQuery();
+ rs.next();
+ // should not reach here
+ fail("HashJoinCacheNotFoundException was not thrown");
+ } finally {
+ if (statement != null) {
+ statement.close();
+ }
+ if (rs != null) {
+ rs.close();
+ }
+ }
+ }
+
+ @Test(expected = HashJoinCacheNotFoundException.class)
+ public void testExpiredCacheWithInnerJoin() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ props.setProperty(QueryServices.MAX_SERVER_CACHE_TIME_TO_LIVE_MS_ATTRIB, "1");
+ PreparedStatement statement = null;
+ ResultSet rs = null;
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ String tableName1 = getTableName(conn, JOIN_SUPPLIER_TABLE_FULL_NAME);
+ String tableName2 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME);
+ final String query =
+ "SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM "
+ + tableName1
+ + " supp INNER JOIN "
+ + tableName2
+ + " item ON item.\"supplier_id\" = supp.\"supplier_id\" ORDER BY \"item_id\"";
+ statement = conn.prepareStatement(query);
+ rs = statement.executeQuery();
+ rs.next();
+ // should not reach here
+ fail("HashJoinCacheNotFoundException was not thrown as expected");
+ } finally {
+ if (statement != null) {
+ statement.close();
+ }
+ if (rs != null) {
+ rs.close();
+ }
+ }
+ }
+
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
index 85ee07d..d3b0286 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
@@ -443,7 +443,7 @@ public class ServerCacheClient {
lastThrowable);
}
} finally {
- cacheUsingTableMap.remove(cacheId);
+ cacheUsingTableMap.remove(Bytes.mapKey(cacheId));
Closeables.closeQuietly(iterateOverTable);
}
}