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/10/31 06:17:03 UTC

[phoenix] branch 4.x updated (7cbebb4 -> a8a9699)

This is an automated email from the ASF dual-hosted git repository.

yanxinyi pushed a change to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git.


    from 7cbebb4  PHOENIX-6171 Child views should not be allowed to override the parent view PHOENIX_TTL attribute.
     new 9ffd740  PHOENIX-6179 : Relax maxLookBackAge check during an upgrade
     new a8a9699  PHOENIX-6087 : Resolve Phoenix Connection leak in UpgradeUtil.addViewIndexToParentLinks() and Admin leak in UpgradeUtil.syncTableAndIndexProperties()

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../phoenix/end2end/BackwardCompatibilityIT.java   |  76 ++++++++--
 .../apache/phoenix/end2end/PropertiesInSyncIT.java |   2 +-
 .../org/apache/phoenix/compile/QueryCompiler.java  |   5 +
 .../phoenix/query/ConnectionQueryServicesImpl.java |   2 +-
 .../java/org/apache/phoenix/util/UpgradeUtil.java  | 168 +++++++++++++--------
 5 files changed, 173 insertions(+), 80 deletions(-)


[phoenix] 02/02: PHOENIX-6087 : Resolve Phoenix Connection leak in UpgradeUtil.addViewIndexToParentLinks() and Admin leak in UpgradeUtil.syncTableAndIndexProperties()

Posted by ya...@apache.org.
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

commit a8a969991fd95b3346f6f6bb72df64915c6dff67
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Fri Oct 30 23:15:51 2020 +0530

    PHOENIX-6087 : Resolve Phoenix Connection leak in UpgradeUtil.addViewIndexToParentLinks() and Admin leak in UpgradeUtil.syncTableAndIndexProperties()
    
    Signed-off-by: Xinyi Yan <ya...@apache.org>
---
 .../apache/phoenix/end2end/PropertiesInSyncIT.java |   2 +-
 .../phoenix/query/ConnectionQueryServicesImpl.java |   2 +-
 .../java/org/apache/phoenix/util/UpgradeUtil.java  | 168 +++++++++++++--------
 3 files changed, 108 insertions(+), 64 deletions(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java
index 30288e5..f8a7519 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java
@@ -401,7 +401,7 @@ public class PropertiesInSyncIT extends ParallelStatsDisabledIT {
         PhoenixConnection upgradeConn = conn.unwrap(PhoenixConnection.class);
         // Simulate an upgrade by setting the upgrade flag
         upgradeConn.setRunningUpgrade(true);
-        syncTableAndIndexProperties(upgradeConn, upgradeConn.getQueryServices().getAdmin());
+        syncTableAndIndexProperties(upgradeConn);
         for (String t: createdTables) {
             verifyHBaseColumnFamilyProperties(t, conn, false, false);
         }
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 62825d2..62c7b03 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -3845,7 +3845,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
             // Synchronize necessary properties amongst all column families of a base table
             // and its indexes. See PHOENIX-3955
             if (syncAllTableAndIndexProps) {
-                syncTableAndIndexProperties(metaConnection, getAdmin());
+                syncTableAndIndexProperties(metaConnection);
             }
 
             // In case namespace mapping is enabled and system table to system namespace mapping is also enabled,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index d15598a..c91fff9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -1190,7 +1190,9 @@ public class UpgradeUtil {
     }
     
     public static void addViewIndexToParentLinks(PhoenixConnection oldMetaConnection) throws SQLException {
-    	// Need to use own connection with max time stamp to be able to read all data from SYSTEM.CATALOG 
+        PhoenixConnection metaConn = null;
+        boolean isMetaConnUsingQueryConn = true;
+    	// Need to use own connection with max time stamp to be able to read all data from SYSTEM.CATALOG
         try (PhoenixConnection queryConn = new PhoenixConnection(oldMetaConnection, HConstants.LATEST_TIMESTAMP);
         		PhoenixConnection upsertConn = new PhoenixConnection(oldMetaConnection, HConstants.LATEST_TIMESTAMP)) {
             LOGGER.info("Upgrading metadata to add parent links for indexes on views");
@@ -1199,36 +1201,56 @@ public class UpgradeUtil {
 			String createViewIndexLink = "UPSERT INTO SYSTEM.CATALOG (TENANT_ID, TABLE_SCHEM, TABLE_NAME, COLUMN_FAMILY, LINK_TYPE) VALUES (?,?,?,?,?) ";
             ResultSet rs = queryConn.createStatement().executeQuery(indexQuery);
             String prevTenantId = null;
-            PhoenixConnection metaConn = queryConn;
+            metaConn = queryConn;
             Properties props = new Properties(queryConn.getClientInfo());
-			props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(HConstants.LATEST_TIMESTAMP));
+            props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
+                Long.toString(HConstants.LATEST_TIMESTAMP));
             while (rs.next()) {
-            	String tenantId = rs.getString("TENANT_ID");
-				if (!java.util.Objects.equals(prevTenantId, tenantId)) {
-					prevTenantId = tenantId;
-					props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
-            		metaConn = new PhoenixConnection(oldMetaConnection, props); 
-            	}
-            	String schemaName = rs.getString("TABLE_SCHEM");
-            	String parentTableName = rs.getString("TABLE_NAME");
-            	String fullParentTableName = SchemaUtil.getTableName(schemaName, parentTableName);
-            	String indexName = rs.getString("COLUMN_FAMILY");
-            	PTable table = PhoenixRuntime.getTable(metaConn, fullParentTableName);
-            	if (table==null) {
-            		throw new TableNotFoundException(fullParentTableName);
-            	}
-            	if (table.getType().equals(PTableType.VIEW)) {
-            		PreparedStatement prepareStatement = upsertConn.prepareStatement(createViewIndexLink);
-            		prepareStatement.setString(1, tenantId);
-            		prepareStatement.setString(2, schemaName);
-            		prepareStatement.setString(3, indexName);
-            		prepareStatement.setString(4, parentTableName);
-            		prepareStatement.setByte(5, LinkType.VIEW_INDEX_PARENT_TABLE.getSerializedValue());
-            		prepareStatement.execute();
-            		upsertConn.commit();
-            	}
+                String tenantId = rs.getString("TENANT_ID");
+                if (!java.util.Objects.equals(prevTenantId, tenantId)) {
+                    prevTenantId = tenantId;
+                    props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
+                    // guard again queryConn because we don't want to close
+                    // queryConn if metaConn was assigned queryConn at
+                    // this point
+                    if (!isMetaConnUsingQueryConn) {
+                        metaConn.close();
+                    }
+                    metaConn = new PhoenixConnection(oldMetaConnection, props);
+                    // now that we have reassigned metaConn, make
+                    // isMetaConnUsingQueryConn false so that we make
+                    // metaConn eligible for closure
+                    isMetaConnUsingQueryConn = false;
+                }
+                String schemaName = rs.getString(TABLE_SCHEM);
+                String parentTableName = rs.getString(TABLE_NAME);
+                String fullParentTableName =
+                    SchemaUtil.getTableName(schemaName, parentTableName);
+                String indexName = rs.getString(COLUMN_FAMILY);
+                PTable table = PhoenixRuntime.getTable(metaConn, fullParentTableName);
+                if (table == null) {
+                    throw new TableNotFoundException(fullParentTableName);
+                }
+                if (table.getType().equals(PTableType.VIEW)) {
+                    PreparedStatement prepareStatement =
+                        upsertConn.prepareStatement(createViewIndexLink);
+                    prepareStatement.setString(1, tenantId);
+                    prepareStatement.setString(2, schemaName);
+                    prepareStatement.setString(3, indexName);
+                    prepareStatement.setString(4, parentTableName);
+                    prepareStatement.setByte(5,
+                        LinkType.VIEW_INDEX_PARENT_TABLE.getSerializedValue());
+                    prepareStatement.execute();
+                    upsertConn.commit();
+                }
             }
             queryConn.getQueryServices().clearCache();
+        } finally {
+            // while iterating through ResultSet, if metaConn was reassigned
+            // anytime, we need to close the last reassigned tenant connection
+            if (!isMetaConnUsingQueryConn) {
+                metaConn.close();
+            }
         }
     }
 
@@ -1426,45 +1448,67 @@ public class UpgradeUtil {
      * with each other and also in sync with all the table's indexes
      * See PHOENIX-3955
      * @param conn Phoenix connection
-     * @param admin HBase admin used for getting existing tables and their descriptors
-     * @throws SQLException
-     * @throws IOException
+     * @throws SQLException if something goes wrong while retrieving Admin,
+     *     Table or while calling underlying utilities like
+     *     {@link #syncUpdateCacheFreqAllIndexes(PhoenixConnection, PTable)} ,
+     *     {@link #addTableDescIfPropsChanged(HTableDescriptor,
+     *         HColumnDescriptor, Map, Set)} ,
+     *     {@link #syncGlobalIndexesForTable(ConnectionQueryServices, PTable,
+     *         HColumnDescriptor, Map, Set)} ,
+     *     {@link #syncViewIndexTable(ConnectionQueryServices, PTable,
+     *         HColumnDescriptor, Map, Set)}
+     * @throws IOException if something goes wrong while retrieving Admin,
+     *     performing admin operations or while performing sync of updated
+     *     cache frequencies for indexes using
+     *     {@link #syncUpdateCacheFreqAllIndexes(PhoenixConnection, PTable)}
      */
-    public static void syncTableAndIndexProperties(PhoenixConnection conn, Admin admin)
-    throws SQLException, IOException {
-        Set<HTableDescriptor> tableDescriptorsToSynchronize = new HashSet<>();
-        for (HTableDescriptor origTableDesc : admin.listTables()) {
-            if (MetaDataUtil.isViewIndex(origTableDesc.getTableName().getNameWithNamespaceInclAsString())) {
-                // Ignore physical view index tables since we handle them for each base table already
-                continue;
-            }
-            PTable table;
-            String fullTableName = SchemaUtil.getPhysicalTableName(
+    public static void syncTableAndIndexProperties(PhoenixConnection conn)
+            throws SQLException, IOException {
+        try (Admin admin = conn.getQueryServices().getAdmin()) {
+            Set<HTableDescriptor> tableDescriptorsToSynchronize =
+                new HashSet<>();
+            for (HTableDescriptor origTableDesc : admin.listTables()) {
+                if (MetaDataUtil.isViewIndex(origTableDesc.getTableName()
+                        .getNameWithNamespaceInclAsString())) {
+                    // Ignore physical view index tables since we handle them
+                    // for each base table already
+                    continue;
+                }
+                PTable table;
+                String fullTableName = SchemaUtil.getPhysicalTableName(
                     origTableDesc.getTableName().getName(),
-                    SchemaUtil.isNamespaceMappingEnabled(
-                            null, conn.getQueryServices().getProps())).getNameAsString();
-            try {
-                // Use this getTable API to get the latest PTable
-                table = PhoenixRuntime.getTable(conn, null, fullTableName);
-            } catch (TableNotFoundException e) {
-                // Ignore tables not mapped to a Phoenix Table
-                LOGGER.warn("Error getting PTable for HBase table: " + fullTableName);
-                continue;
+                    SchemaUtil.isNamespaceMappingEnabled(null,
+                        conn.getQueryServices().getProps())).getNameAsString();
+                try {
+                    // Use this getTable API to get the latest PTable
+                    table = PhoenixRuntime.getTable(conn, null, fullTableName);
+                } catch (TableNotFoundException e) {
+                    // Ignore tables not mapped to a Phoenix Table
+                    LOGGER.warn("Error getting PTable for HBase table: {}",
+                        fullTableName);
+                    continue;
+                }
+                if (table.getType() == PTableType.INDEX) {
+                    // Ignore global index tables since we handle them for
+                    // each base table already
+                    continue;
+                }
+                syncUpdateCacheFreqAllIndexes(conn, table);
+                HColumnDescriptor defaultColFam = origTableDesc
+                    .getFamily(SchemaUtil.getEmptyColumnFamily(table));
+                Map<String, Object> syncedProps =
+                    MetaDataUtil.getSyncedProps(defaultColFam);
+
+                addTableDescIfPropsChanged(origTableDesc, defaultColFam,
+                    syncedProps, tableDescriptorsToSynchronize);
+                syncGlobalIndexesForTable(conn.getQueryServices(), table,
+                    defaultColFam, syncedProps, tableDescriptorsToSynchronize);
+                syncViewIndexTable(conn.getQueryServices(), table,
+                    defaultColFam, syncedProps, tableDescriptorsToSynchronize);
             }
-            if (table.getType() == PTableType.INDEX) {
-                // Ignore global index tables since we handle them for each base table already
-                continue;
+            for (HTableDescriptor t : tableDescriptorsToSynchronize) {
+                admin.modifyTable(t.getTableName(), t);
             }
-            syncUpdateCacheFreqAllIndexes(conn, table);
-            HColumnDescriptor defaultColFam = origTableDesc.getFamily(SchemaUtil.getEmptyColumnFamily(table));
-            Map<String, Object> syncedProps = MetaDataUtil.getSyncedProps(defaultColFam);
-
-            addTableDescIfPropsChanged(origTableDesc, defaultColFam, syncedProps, tableDescriptorsToSynchronize);
-            syncGlobalIndexesForTable(conn.getQueryServices(), table, defaultColFam, syncedProps, tableDescriptorsToSynchronize);
-            syncViewIndexTable(conn.getQueryServices(), table, defaultColFam, syncedProps, tableDescriptorsToSynchronize);
-        }
-        for (HTableDescriptor t: tableDescriptorsToSynchronize) {
-            admin.modifyTable(t.getTableName(), t);
         }
     }
 


[phoenix] 01/02: PHOENIX-6179 : Relax maxLookBackAge check during an upgrade

Posted by ya...@apache.org.
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

commit 9ffd740f2ee851abc485a9c283c741dce105dab4
Author: Viraj Jasani <vj...@apache.org>
AuthorDate: Tue Oct 27 23:29:15 2020 +0530

    PHOENIX-6179 : Relax maxLookBackAge check during an upgrade
    
    Signed-off-by: Xinyi Yan <ya...@apache.org>
---
 .../phoenix/end2end/BackwardCompatibilityIT.java   | 76 +++++++++++++++++-----
 .../org/apache/phoenix/compile/QueryCompiler.java  |  5 ++
 2 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
index d20610a..731d045 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.regionserver.ScanInfoUtil;
 import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.phoenix.coprocessor.MetaDataProtocol;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
@@ -179,7 +180,7 @@ public class BackwardCompatibilityIT {
     public void testUpsertWithOldClient() throws Exception {
         // Insert data with old client and read with new client
         executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
-        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD, false);
         assertExpectedOutput(QUERY_CREATE_ADD);
     }
 
@@ -187,7 +188,16 @@ public class BackwardCompatibilityIT {
     public void testCreateDivergedViewWithOldClientReadFromNewClient() throws Exception {
         // Create a base table, view and make it diverge from an old client
         executeQueryWithClientVersion(compatibleClientVersion, CREATE_DIVERGED_VIEW);
-        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW, false);
+        assertExpectedOutput(QUERY_CREATE_DIVERGED_VIEW);
+    }
+
+    @Test
+    public void testCreateDivergedViewWithOldClientReadWithMaxLookBackAge()
+            throws Exception {
+        // Create a base table, view and make it diverge from an old client
+        executeQueryWithClientVersion(compatibleClientVersion, CREATE_DIVERGED_VIEW);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW, true);
         assertExpectedOutput(QUERY_CREATE_DIVERGED_VIEW);
     }
 
@@ -214,15 +224,15 @@ public class BackwardCompatibilityIT {
 
     @Test
     public void testCreateDivergedViewWithNewClientReadFromOldClient() throws Exception {
-        executeQueriesWithCurrentVersion(CREATE_DIVERGED_VIEW);
+        executeQueriesWithCurrentVersion(CREATE_DIVERGED_VIEW, false);
         executeQueryWithClientVersion(compatibleClientVersion, QUERY_CREATE_DIVERGED_VIEW);
         assertExpectedOutput(QUERY_CREATE_DIVERGED_VIEW);
     }
 
     @Test
     public void testCreateDivergedViewWithNewClientReadFromNewClient() throws Exception {
-        executeQueriesWithCurrentVersion(CREATE_DIVERGED_VIEW);
-        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW);
+        executeQueriesWithCurrentVersion(CREATE_DIVERGED_VIEW, false);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW, false);
         assertExpectedOutput(QUERY_CREATE_DIVERGED_VIEW);
     }
 
@@ -237,7 +247,7 @@ public class BackwardCompatibilityIT {
     @Test
     public void testSelectWithOldClient() throws Exception {
         // Insert data with new client and read with old client
-        executeQueriesWithCurrentVersion(CREATE_ADD);
+        executeQueriesWithCurrentVersion(CREATE_ADD, false);
         executeQueryWithClientVersion(compatibleClientVersion, QUERY_CREATE_ADD);
         assertExpectedOutput(QUERY_CREATE_ADD);
     }
@@ -249,18 +259,43 @@ public class BackwardCompatibilityIT {
      * 3. New Client reads the data inserted by the old client 
      * 4. New Client inserts more data into the tables created by old client 
      * 5. Old Client reads the data inserted by new client
+     * Use phoenix.max.lookback.age.seconds config and ensure that upgrade
+     * is not impacted by the config.
      * 
      * @throws Exception thrown if any errors encountered during query execution or file IO
      */
     @Test
+    public void testSelectUpsertWithNewClientWithMaxLookBackAge() throws Exception {
+        // Insert data with old client and read with new client
+        executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD, true);
+        assertExpectedOutput(QUERY_CREATE_ADD);
+
+        // Insert more data with new client and read with old client
+        executeQueriesWithCurrentVersion(ADD_DATA, true);
+        executeQueryWithClientVersion(compatibleClientVersion, QUERY_ADD_DATA);
+        assertExpectedOutput(QUERY_ADD_DATA);
+    }
+
+    /**
+     * Scenario:
+     * 1. Old Client connects to the updated server
+     * 2. Old Client creates tables and inserts data
+     * 3. New Client reads the data inserted by the old client
+     * 4. New Client inserts more data into the tables created by old client
+     * 5. Old Client reads the data inserted by new client
+     *
+     * @throws Exception thrown if any errors encountered during query execution or file IO
+     */
+    @Test
     public void testSelectUpsertWithNewClient() throws Exception {
         // Insert data with old client and read with new client
         executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
-        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD, false);
         assertExpectedOutput(QUERY_CREATE_ADD);
 
         // Insert more data with new client and read with old client
-        executeQueriesWithCurrentVersion(ADD_DATA);
+        executeQueriesWithCurrentVersion(ADD_DATA, false);
         executeQueryWithClientVersion(compatibleClientVersion, QUERY_ADD_DATA);
         assertExpectedOutput(QUERY_ADD_DATA);
     }
@@ -278,13 +313,13 @@ public class BackwardCompatibilityIT {
     @Test
     public void testSelectUpsertWithOldClient() throws Exception {
         // Insert data with new client and read with old client
-        executeQueriesWithCurrentVersion(CREATE_ADD);
+        executeQueriesWithCurrentVersion(CREATE_ADD, false);
         executeQueryWithClientVersion(compatibleClientVersion, QUERY_CREATE_ADD);
         assertExpectedOutput(QUERY_CREATE_ADD);
 
         // Insert more data with old client and read with new client
         executeQueryWithClientVersion(compatibleClientVersion, ADD_DATA);
-        executeQueriesWithCurrentVersion(QUERY_ADD_DATA);
+        executeQueriesWithCurrentVersion(QUERY_ADD_DATA, false);
         assertExpectedOutput(QUERY_ADD_DATA);
     }
 
@@ -301,7 +336,7 @@ public class BackwardCompatibilityIT {
     public void testUpsertDeleteWithOldClient() throws Exception {
         // Insert data with old client and read with new client
         executeQueryWithClientVersion(compatibleClientVersion, CREATE_ADD);
-        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_ADD, false);
         assertExpectedOutput(QUERY_CREATE_ADD);
 
         // Deletes with the old client
@@ -322,13 +357,13 @@ public class BackwardCompatibilityIT {
     @Test
     public void testUpsertDeleteWithNewClient() throws Exception {
         // Insert data with old client and read with new client
-        executeQueriesWithCurrentVersion(CREATE_ADD);
+        executeQueriesWithCurrentVersion(CREATE_ADD, false);
         executeQueryWithClientVersion(compatibleClientVersion, QUERY_CREATE_ADD);
         assertExpectedOutput(QUERY_CREATE_ADD);
 
         // Deletes with the new client
-        executeQueriesWithCurrentVersion(ADD_DELETE);
-        executeQueriesWithCurrentVersion(QUERY_ADD_DELETE);
+        executeQueriesWithCurrentVersion(ADD_DELETE, false);
+        executeQueriesWithCurrentVersion(QUERY_ADD_DELETE, false);
         assertExpectedOutput(QUERY_ADD_DELETE);
     }
 
@@ -336,7 +371,7 @@ public class BackwardCompatibilityIT {
     public void testUpdatedSplitPolicyForSysTask() throws Exception {
         executeQueryWithClientVersion(compatibleClientVersion,
             CREATE_DIVERGED_VIEW);
-        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW);
+        executeQueriesWithCurrentVersion(QUERY_CREATE_DIVERGED_VIEW, false);
         try (org.apache.hadoop.hbase.client.Connection conn =
                 hbaseTestUtil.getConnection(); Admin admin = conn.getAdmin()) {
             HTableDescriptor tableDescriptor = admin.getTableDescriptor(
@@ -433,8 +468,17 @@ public class BackwardCompatibilityIT {
     }
 
     // Executes the SQL commands listed in the given operation file from the sql_files directory
-    private void executeQueriesWithCurrentVersion(String operation) throws Exception {
+    private void executeQueriesWithCurrentVersion(String operation,
+            boolean setMaxLookBackAge) throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        if (setMaxLookBackAge) {
+            props.put(
+                QueryServices.GLOBAL_INDEX_ROW_AGE_THRESHOLD_TO_DELETE_MS_ATTRIB,
+                    Long.toString(0));
+            props.put(ScanInfoUtil.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY,
+                Integer.toString(15));
+        }
+
         try (Connection conn = DriverManager.getConnection(url, props)) {
             StringBuilder sb = new StringBuilder();
             try (BufferedReader reader =
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 5f75e8b..58565de 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
@@ -170,6 +170,11 @@ public class QueryCompiler {
 
     private void verifySCN() throws SQLException {
         PhoenixConnection conn = statement.getConnection();
+        if (conn.isRunningUpgrade()) {
+            // PHOENIX-6179 : if upgrade is going on, we don't need to
+            // perform MaxLookBackAge check
+            return;
+        }
         Long scn = conn.getSCN();
         if (scn == null) {
             return;