[
https://issues.apache.org/jira/browse/PHOENIX-6192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17218502#comment-17218502
]
ASF GitHub Bot commented on PHOENIX-6192:
-----------------------------------------
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:
[email protected]
> UpgradeUtil.syncUpdateCacheFreqAllIndexes() does not use tenant-specific
> connection to resolve tenant views
> -----------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-6192
> URL: https://issues.apache.org/jira/browse/PHOENIX-6192
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 5.0.0, 4.15.0
> Reporter: Chinmay Kulkarni
> Assignee: Viraj Jasani
> Priority: Major
> Fix For: 5.1.0, 4.16.0
>
>
> In UpgradeUtil.synchUpdateCacheFreqAllIndexes(), we try to retrieve all child
> views of each table to make all the view index UPDATE_CACHE_FREQUENCY
> property values in sync with the view.
> Here however, when iterating over the parent->child link results, we don't
> use a tenant-specific connection to retrieve a tenant view leading to the
> PTable resolution failing (see
> [this|https://github.com/apache/phoenix/blob/264310bd1e6c14996c3cfb11557fc66a012cb01b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java#L1369])
--
This message was sent by Atlassian Jira
(v8.3.4#803005)