You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/10/19 13:20:23 UTC

[GitHub] [phoenix] virajjasani opened a new pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

virajjasani opened a new pull request #928:
URL: https://github.com/apache/phoenix/pull/928


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani commented on pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
virajjasani commented on pull request #928:
URL: https://github.com/apache/phoenix/pull/928#issuecomment-714468218


   Thanks for the review @ChinmaySKulkarni @yanxinyi . I have addressed your comments, could you please take a look?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] yanxinyi commented on pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
yanxinyi commented on pull request #928:
URL: https://github.com/apache/phoenix/pull/928#issuecomment-713810637


   @virajjasani thanks for the patch. Can you rebase and solve the conflict? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] yanxinyi commented on a change in pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
yanxinyi commented on a change in pull request #928:
URL: https://github.com/apache/phoenix/pull/928#discussion_r509540735



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);

Review comment:
       nit: maybe use tableNameFreqVal instead of entering a numerical value?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] ChinmaySKulkarni commented on a change in pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on a change in pull request #928:
URL: https://github.com/apache/phoenix/pull/928#discussion_r509507594



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);

Review comment:
       nit: Not sure we need to assign `rs.get..()` to a variable each time for `tenantId`, `ucf`, etc. Up to you if you think it's good for clarity (I don't feel strongly about it).

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {

Review comment:
       Just wondering, can these tests can't be added to `GlobalConnectionTenantTableIT` itself? 

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -1400,6 +1393,43 @@ public static void syncUpdateCacheFreqAllIndexes(PhoenixConnection conn, PTable
         }
     }
 
+    private static void iterateOverChildViewAndSyncCacheFreq(
+            final PhoenixConnection newConn,
+            final PreparedStatement stmt, final TableInfo tableInfo)
+            throws SQLException {
+        String viewName = SchemaUtil.getTableName(tableInfo.getSchemaName(),
+            tableInfo.getTableName());
+        String viewTenantId = Bytes.toString(tableInfo.getTenantId());

Review comment:
       It will be better to resolve the PTable for the view (either using tenanted connection if required or a global connection if a global view) and then call `syncUpdateCacheFreqForIndexesOfTable()` just once. Basically, combine this method and `getViewAndSyncCacheFreqForIndexes()`.

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -1400,6 +1393,43 @@ public static void syncUpdateCacheFreqAllIndexes(PhoenixConnection conn, PTable
         }
     }
 
+    private static void iterateOverChildViewAndSyncCacheFreq(
+            final PhoenixConnection newConn,
+            final PreparedStatement stmt, final TableInfo tableInfo)
+            throws SQLException {
+        String viewName = SchemaUtil.getTableName(tableInfo.getSchemaName(),
+            tableInfo.getTableName());
+        String viewTenantId = Bytes.toString(tableInfo.getTenantId());
+        if (StringUtils.isNotEmpty(viewTenantId)) {
+            Properties props = new Properties(newConn.getClientInfo());
+            props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, viewTenantId);
+            // use tenant connection to resolve tenant views
+            try (PhoenixConnection tenantConn =
+                    new PhoenixConnection(newConn, props)) {
+                getViewAndSyncCacheFreqForIndexes(stmt, viewName,
+                    viewTenantId, tenantConn);
+            }
+        } else {
+            getViewAndSyncCacheFreqForIndexes(stmt, viewName,
+                viewTenantId, newConn);
+        }
+    }
+
+    private static void getViewAndSyncCacheFreqForIndexes(
+            final PreparedStatement stmt, final String viewName,
+            final String viewTenantId, final PhoenixConnection conn)
+            throws SQLException {
+        final PTable view;
+        try {
+            view = PhoenixRuntime.getTable(conn, viewName);
+        } catch (TableNotFoundException e) {
+            // Ignore
+            LOGGER.warn("Error getting PTable for view: {}", viewName);

Review comment:
       This should be `ERROR` level

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {

Review comment:
       In case the answer is no for some reason, can we rename this test class to be more representative of the actual test i.e. all tests are related to syncUpdateCacheFreq so maybe rename it to show that

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);
+            updateCacheFreq(conn, null, TABLE_INDEX, 400);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_INDEX + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(400, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG "
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_INDEX_NAME, 888);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(888, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            // clear the server-side cache to get the latest built PTables
+            conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache();
+            PhoenixConnection pcon = conn.unwrap(PhoenixConnection.class);
+            pcon.setRunningUpgrade(true);
+
+            UpgradeUtil.syncUpdateCacheFreqAllIndexes(pcon,
+                PhoenixRuntime.getTableNoCache(conn, SchemaUtil.getTableName(SCHEMA_NAME, TABLE_NAME)));
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM"
+                    + " SYSTEM.CATALOG WHERE TABLE_NAME='" + TABLE_NAME + "'");
+            rs.next();
+            String tenantId = rs.getString(1);
+            String schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"

Review comment:
       Extract this query into a `private final String` member variable to avoid duplication

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);
+            updateCacheFreq(conn, null, TABLE_INDEX, 400);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_INDEX + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(400, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG "
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_INDEX_NAME, 888);
+
+            rs = conn.createStatement().executeQuery(

Review comment:
       nit: these 4-5 steps are repeated multiple times so maybe worth extracting to a small helper method..something like `assertUpdateCacheFreqValue()`)

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);
+            updateCacheFreq(conn, null, TABLE_INDEX, 400);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_INDEX + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(400, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG "
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_INDEX_NAME, 888);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(888, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            // clear the server-side cache to get the latest built PTables
+            conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache();
+            PhoenixConnection pcon = conn.unwrap(PhoenixConnection.class);
+            pcon.setRunningUpgrade(true);
+
+            UpgradeUtil.syncUpdateCacheFreqAllIndexes(pcon,
+                PhoenixRuntime.getTableNoCache(conn, SchemaUtil.getTableName(SCHEMA_NAME, TABLE_NAME)));
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM"
+                    + " SYSTEM.CATALOG WHERE TABLE_NAME='" + TABLE_NAME + "'");
+            rs.next();
+            String tenantId = rs.getString(1);
+            String schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + TABLE_INDEX + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME, tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW2_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(0, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW2_INDEX_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+        }
+    }
+
+    private void updateCacheFreq(Connection conn, String tenantId,

Review comment:
       nit: Maybe this method should be called `updateUpdateCacheFreq()` ;)

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);
+            updateCacheFreq(conn, null, TABLE_INDEX, 400);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_INDEX + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(400, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG "
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_INDEX_NAME, 888);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(888, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            // clear the server-side cache to get the latest built PTables
+            conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache();
+            PhoenixConnection pcon = conn.unwrap(PhoenixConnection.class);
+            pcon.setRunningUpgrade(true);
+
+            UpgradeUtil.syncUpdateCacheFreqAllIndexes(pcon,
+                PhoenixRuntime.getTableNoCache(conn, SchemaUtil.getTableName(SCHEMA_NAME, TABLE_NAME)));
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM"
+                    + " SYSTEM.CATALOG WHERE TABLE_NAME='" + TABLE_NAME + "'");
+            rs.next();
+            String tenantId = rs.getString(1);
+            String schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + TABLE_INDEX + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME, tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);

Review comment:
       Shouldn't this be 999 since the view it is an index of has 999 set?

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);

Review comment:
       Would be better to try out a couple of different TENANT_IDs to make sure that `syncUpdateCacheFreqAllIndexes()` changes the tenant_id to use as per each view that is found

##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
##########
@@ -1400,6 +1393,43 @@ public static void syncUpdateCacheFreqAllIndexes(PhoenixConnection conn, PTable
         }
     }
 
+    private static void iterateOverChildViewAndSyncCacheFreq(

Review comment:
       Rename this method since we aren't iterating over anything. Maybe after combining this with `getViewAndSyncCacheFreqForIndexes()` we can just call it the latter.

##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);
+            updateCacheFreq(conn, null, TABLE_INDEX, 400);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_INDEX + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(400, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG "
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_INDEX_NAME, 888);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(888, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + VIEW2_INDEX_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            // clear the server-side cache to get the latest built PTables
+            conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache();
+            PhoenixConnection pcon = conn.unwrap(PhoenixConnection.class);
+            pcon.setRunningUpgrade(true);
+
+            UpgradeUtil.syncUpdateCacheFreqAllIndexes(pcon,
+                PhoenixRuntime.getTableNoCache(conn, SchemaUtil.getTableName(SCHEMA_NAME, TABLE_NAME)));
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM"
+                    + " SYSTEM.CATALOG WHERE TABLE_NAME='" + TABLE_NAME + "'");
+            rs.next();
+            String tenantId = rs.getString(1);
+            String schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + TABLE_INDEX + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertNull(tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME, tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(999, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW1_INDEX_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW2_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(0, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT TENANT_ID,TABLE_SCHEM,UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG"
+                    + " WHERE TABLE_NAME='" + VIEW2_INDEX_NAME + "'");
+            rs.next();
+            tenantId = rs.getString(1);
+            schemaName = rs.getString(2);
+            cacheFreq = rs.getLong(3);
+            assertEquals(TENANT_NAME,tenantId);
+            assertEquals(SCHEMA_NAME, schemaName);
+            assertEquals(500, cacheFreq);

Review comment:
       Similarly, shouldn't this be 0 since VIEW2 has 0 set?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #928:
URL: https://github.com/apache/phoenix/pull/928#issuecomment-714610358


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   6m 42s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  No case conflicting files found.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  0s |  The patch does not contain any @author tags.  |
   | -1 :x: |  test4tests  |   0m  0s |  The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.  |
   ||| _ master Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  15m 46s |  master passed  |
   | +1 :green_heart: |  compile  |   1m 11s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   1m  1s |  master passed  |
   | +1 :green_heart: |  javadoc  |   1m  1s |  master passed  |
   | +0 :ok: |  spotbugs  |   3m 59s |  phoenix-core in master has 970 extant spotbugs warnings.  |
   ||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  10m 11s |  the patch passed  |
   | +1 :green_heart: |  compile  |   1m  9s |  the patch passed  |
   | +1 :green_heart: |  javac  |   1m  9s |  the patch passed  |
   | -1 :x: |  checkstyle  |   1m  0s |  phoenix-core: The patch generated 4 new + 1296 unchanged - 3 fixed = 1300 total (was 1299)  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  javadoc  |   0m 55s |  the patch passed  |
   | +1 :green_heart: |  spotbugs  |   4m  2s |  the patch passed  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  | 174m 50s |  phoenix-core in the patch failed.  |
   | +1 :green_heart: |  asflicense  |   0m 28s |  The patch does not generate ASF License warnings.  |
   |  |   | 225m  0s |   |
   
   
   | Reason | Tests |
   |-------:|:------|
   | Failed junit tests | phoenix.end2end.index.IndexUsageIT |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/artifact/yetus-general-check/output/Dockerfile |
   | GITHUB PR | https://github.com/apache/phoenix/pull/928 |
   | Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile |
   | uname | Linux 0da729dfccb7 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev/phoenix-personality.sh |
   | git revision | master / 8c81131 |
   | Default Java | Private Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08 |
   | checkstyle | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt |
   | unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt |
   |  Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/testReport/ |
   | Max. process+thread count | 6823 (vs. ulimit of 30000) |
   | modules | C: phoenix-core U: phoenix-core |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/4/console |
   | versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] virajjasani closed pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
virajjasani closed pull request #928:
URL: https://github.com/apache/phoenix/pull/928


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #928:
URL: https://github.com/apache/phoenix/pull/928#issuecomment-714466708


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   0m  0s |  Docker mode activated.  |
   | -1 :x: |  docker  |   3m 33s |  Docker failed to build yetus/phoenix:10ef71711.  |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | GITHUB PR | https://github.com/apache/phoenix/pull/928 |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/3/console |
   | versions | git=2.17.1 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] yanxinyi commented on a change in pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
yanxinyi commented on a change in pull request #928:
URL: https://github.com/apache/phoenix/pull/928#discussion_r509591674



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);
+            updateCacheFreq(conn, null, TABLE_INDEX, 400);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_INDEX + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(400, cacheFreq);
+
+            rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG "
+                    + " WHERE TABLE_NAME='" + VIEW1_NAME + "'");
+            rs.next();
+            cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, TENANT_NAME, VIEW1_NAME, 999);

Review comment:
       nit: maybe use viewName1FreqVal instead of entering a numerical value?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [phoenix] stoty commented on pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #928:
URL: https://github.com/apache/phoenix/pull/928#issuecomment-712337520


   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime | Comment |
   |:----:|----------:|--------:|:--------|
   | +0 :ok: |  reexec  |   1m  6s |  Docker mode activated.  |
   ||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  No case conflicting files found.  |
   | +1 :green_heart: |  hbaseanti  |   0m  0s |  Patch does not have any anti-patterns.  |
   | +1 :green_heart: |  @author  |   0m  0s |  The patch does not contain any @author tags.  |
   | -1 :x: |  test4tests  |   0m  0s |  The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.  |
   ||| _ master Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  36m 32s |  master passed  |
   | +1 :green_heart: |  compile  |   0m 57s |  master passed  |
   | +1 :green_heart: |  checkstyle  |   0m 59s |  master passed  |
   | +1 :green_heart: |  javadoc  |   0m 43s |  master passed  |
   | +0 :ok: |  spotbugs  |   2m 51s |  phoenix-core in master has 973 extant spotbugs warnings.  |
   ||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  32m 54s |  the patch passed  |
   | +1 :green_heart: |  compile  |   0m 50s |  the patch passed  |
   | +1 :green_heart: |  javac  |   0m 50s |  the patch passed  |
   | -1 :x: |  checkstyle  |   1m  0s |  phoenix-core: The patch generated 12 new + 1278 unchanged - 11 fixed = 1290 total (was 1289)  |
   | +1 :green_heart: |  whitespace  |   0m  0s |  The patch has no whitespace issues.  |
   | +1 :green_heart: |  javadoc  |   0m 42s |  the patch passed  |
   | +1 :green_heart: |  spotbugs  |   3m  2s |  the patch passed  |
   ||| _ Other Tests _ |
   | -1 :x: |  unit  | 172m 45s |  phoenix-core in the patch failed.  |
   | +1 :green_heart: |  asflicense  |   0m 26s |  The patch does not generate ASF License warnings.  |
   |  |   | 257m 29s |   |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.40 ServerAPI=1.40 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/artifact/yetus-general-check/output/Dockerfile |
   | GITHUB PR | https://github.com/apache/phoenix/pull/928 |
   | Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile |
   | uname | Linux 1884fa74806d 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev/phoenix-personality.sh |
   | git revision | master / 5b58d9b |
   | Default Java | Private Build-1.8.0_242-8u242-b08-0ubuntu3~16.04-b08 |
   | checkstyle | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/artifact/yetus-general-check/output/diff-checkstyle-phoenix-core.txt |
   | unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/artifact/yetus-general-check/output/patch-unit-phoenix-core.txt |
   |  Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/testReport/ |
   | Max. process+thread count | 6751 (vs. ulimit of 30000) |
   | modules | C: phoenix-core U: phoenix-core |
   | Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-928/2/console |
   | versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 |
   | Powered by | Apache Yetus 0.12.0 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org