From 5fd6683c5cba75ead5de6445d0639eabf79a9c05 Mon Sep 17 00:00:00 2001 From: Geoffrey Jacoby Date: Tue, 21 Jan 2020 15:50:32 -0800 Subject: [PATCH] PHOENIX-5692 - SCN verification breaks with non-default column families --- .../src/it/java/org/apache/phoenix/end2end/SCNIT.java | 2 +- .../java/org/apache/phoenix/compile/QueryCompiler.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java index d79752e10ff..8512028c8dd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java @@ -143,7 +143,7 @@ private String createTableWithTTL(int ttl) throws SQLException, InterruptedExcep try (Connection conn = DriverManager.getConnection(getUrl())) { conn.createStatement() .execute(String.format("CREATE TABLE %s" + - "(k VARCHAR PRIMARY KEY, v VARCHAR) %s", fullTableName, ddlOptions)); + "(k VARCHAR PRIMARY KEY, f.v VARCHAR) %s", fullTableName, ddlOptions)); conn.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES('a','aa')"); conn.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES('b','bb')"); conn.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES('c','cc')"); diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java index 4722bd645f8..8afd111a488 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java @@ -191,10 +191,13 @@ private void verifySCN() throws SQLException { //we can have a tableRef with an empty table, such as with sequences if (tableQualifier.length > 0) { HTableDescriptor td = conn.getQueryServices().getTableDescriptor(tableQualifier); - HColumnDescriptor cd = td.getFamily(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES); + HColumnDescriptor[] cds = td.getColumnFamilies(); now = EnvironmentEdgeManager.currentTimeMillis(); - if (now - cd.getTimeToLive() * 1000L > scn) { - scnTooOldTableRefs.add(tableRef); + if (cds.length > 0){ + //Phoenix only allows a single table level TTL, so any CF will do + if (now - cds[0].getTimeToLive() * 1000L > scn) { + scnTooOldTableRefs.add(tableRef); + } } } }