You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ya...@apache.org on 2020/12/08 19:28:09 UTC
[phoenix] branch 4.x updated: PHOENIX-6246 : Remove flakes from
PointInTimeQueryIT (ADDENDUM)
This is an automated email from the ASF dual-hosted git repository.
yanxinyi pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push:
new e648b04 PHOENIX-6246 : Remove flakes from PointInTimeQueryIT (ADDENDUM)
e648b04 is described below
commit e648b04e0ef51a892af352465a067b48362669e0
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Tue Dec 8 17:33:24 2020 +0530
PHOENIX-6246 : Remove flakes from PointInTimeQueryIT (ADDENDUM)
Signed-off-by: Xinyi Yan <ya...@apache.org>
---
.../org/apache/phoenix/end2end/BaseQueryIT.java | 35 ++++++++++++----------
.../phoenix/end2end/PointInTimeScanQueryIT.java | 11 ++++---
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
index 05c6e5f..daf2454 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
@@ -22,22 +22,19 @@ import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
+import java.sql.SQLTimeoutException;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
-import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import com.google.common.collect.Lists;
import org.apache.phoenix.util.PropertiesUtil;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.AfterParam;
import org.junit.runners.Parameterized.BeforeParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.Lists;
-
-
/**
*
@@ -46,20 +43,17 @@ import com.google.common.collect.Lists;
*
* @since 0.1
*/
-
@RunWith(Parameterized.class)
public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
protected static final String tenantId = getOrganizationId();
- protected static final String ATABLE_INDEX_NAME = "ATABLE_IDX";
- protected static final long BATCH_SIZE = 3;
protected static final String NO_INDEX = "";
protected static final String[] GLOBAL_INDEX_DDLS =
new String[] {
- "CREATE INDEX %s ON %s (a_integer DESC) INCLUDE (" + " A_STRING, "
+ "CREATE INDEX IF NOT EXISTS %s ON %s (a_integer DESC) INCLUDE (" + " A_STRING, "
+ " B_STRING, " + " A_DATE)",
- "CREATE INDEX %s ON %s (a_integer, a_string) INCLUDE (" + " B_STRING, "
+ "CREATE INDEX IF NOT EXISTS %s ON %s (a_integer, a_string) INCLUDE (" + " B_STRING, "
+ " A_DATE)",
- "CREATE INDEX %s ON %s (a_integer) INCLUDE (" + " A_STRING, "
+ "CREATE INDEX IF NOT EXISTS %s ON %s (a_integer) INCLUDE (" + " A_STRING, "
+ " B_STRING, " + " A_DATE)",
NO_INDEX };
protected static final String[] LOCAL_INDEX_DDLS =
@@ -100,10 +94,10 @@ public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
}
String tableDDLOptions = optionBuilder.toString();
try {
- tableName =
- initATableValues(generateUniqueName(), tenantId, getDefaultSplits(tenantId),
- date = new Date(System.currentTimeMillis()), null, getUrl(),
- tableDDLOptions);
+ tableName = initATableValues(generateUniqueName(), tenantId,
+ getDefaultSplits(tenantId),
+ date = new Date(System.currentTimeMillis()), null, getUrl(),
+ tableDDLOptions);
} catch (Exception e) {
LOGGER.error("Exception when creating aTable ", e);
throw e;
@@ -113,14 +107,23 @@ public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
String indexDDL =
String.format(idxDdl, indexName, tableName);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ props.setProperty("phoenix.query.timeoutMs", "30000");
try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
conn.createStatement().execute(indexDDL);
+ } catch (SQLTimeoutException e) {
+ LOGGER.info("Query timed out. Retrying one more time.", e);
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.createStatement().execute(indexDDL);
+ } catch (Exception ex) {
+ LOGGER.error("Exception while creating index during second retry: "
+ + indexDDL, ex);
+ throw ex;
+ }
} catch (Exception e) {
LOGGER.error("Exception while creating index: " + indexDDL, e);
throw e;
}
}
-
}
public BaseQueryIT(String idxDdl, boolean columnEncoded, boolean keepDeletedCells) {
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java
index bf5a343..1bbf546 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java
@@ -88,7 +88,7 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
long timeDelta = 100;
Thread.sleep(timeDelta);
- try(Connection upsertConn = DriverManager.getConnection(url, props)) {
+ try (Connection upsertConn = DriverManager.getConnection(url, props)) {
upsertConn.setAutoCommit(true); // Test auto commit
PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
stmt.setString(1, tenantId);
@@ -102,7 +102,7 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
+ tableName + " WHERE organization_id=? and a_integer = 5";
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
Long.toString(queryTime));
- try(Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
ResultSet rs = statement.executeQuery();
@@ -129,8 +129,7 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
" ENTITY_ID, " +
" A_INTEGER) " +
"VALUES (?, ?, ?)";
- try(Connection upsertConn = DriverManager.getConnection(url, props)) {
-
+ try (Connection upsertConn = DriverManager.getConnection(url, props)) {
upsertConn.setAutoCommit(true); // Test auto commit
// Insert all rows at ts
PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
@@ -165,9 +164,9 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
ResultSet rs = statement.executeQuery();
List<List<Object>> expectedResultsA = Lists.newArrayList(
Arrays.<Object>asList(2, C_VALUE),
- Arrays.<Object>asList( 3, E_VALUE));
+ Arrays.<Object>asList(3, E_VALUE));
List<List<Object>> expectedResultsB = Lists.newArrayList(
- Arrays.<Object>asList( 5, C_VALUE),
+ Arrays.<Object>asList(5, C_VALUE),
Arrays.<Object>asList(4, B_VALUE));
// Since we're not ordering and we may be using a descending index, we don't
// know which rows we'll get back.