palashc commented on code in PR #1575: URL: https://github.com/apache/phoenix/pull/1575#discussion_r1240106315
########## phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanChildLinkRowsIT.java: ########## @@ -0,0 +1,270 @@ +/* + * 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.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.client.ResultScanner; +import org.apache.hadoop.hbase.client.Scan; +import org.apache.phoenix.coprocessor.tasks.ChildLinkScanTask; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.query.BaseTest; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.TableAlreadyExistsException; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.EncodedColumnsUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.SchemaUtil; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME; +import static org.apache.phoenix.query.QueryConstants.VERIFIED_BYTES; + +@Category(NeedsOwnMiniClusterTest.class) +@RunWith(Parameterized.class) +public class OrphanChildLinkRowsIT extends BaseTest { + + private final boolean pagingEnabled; + private final String CREATE_TABLE_DDL = "CREATE TABLE %s (TENANT_ID VARCHAR NOT NULL, A INTEGER NOT NULL, B INTEGER CONSTRAINT PK PRIMARY KEY (TENANT_ID, A))"; + private final String CREATE_VIEW_DDL = "CREATE VIEW %s (NEW_COL1 INTEGER, NEW_COL2 INTEGER) AS SELECT * FROM %s WHERE B > 10"; + + public OrphanChildLinkRowsIT(boolean pagingEnabled) { + this.pagingEnabled = pagingEnabled; + } + + @Parameterized.Parameters(name="OrphanChildLinkRowsIT_pagingEnabled={0}") + public static synchronized Collection<Boolean> data() { + return Arrays.asList(false, true); + } + + @BeforeClass + public static synchronized void doSetup() throws Exception { + Map<String, String> props = Maps.newHashMapWithExpectedSize(1); + props.put(QueryServices.CHILD_LINK_ROW_AGE_THRESHOLD_TO_DELETE_MS_ATTRIB, "0"); + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } + + /** + * Disable the child link scan task. + * Create tables T1 and T2. Create 3 views on T1. + * Create a view (same name as existing view on T1) on T2. This CREATE VIEW will fail. + * Verify if there was no orphan child link from T2. + * + * Instrument CQSI to fail phase three of CREATE VIEW. Create a new view V4 on T2 (passes) and V1 on T2 which will fail. + * Both links T2->V4 and T2->V1 will be in UNVERIFIED state, repaired during read. + * Check if T2 has only 1 child link. + */ + @Test + public void testNoOrphanChildLinkRow() throws Exception { Review Comment: @tkhurana this test uses a helper method to query the child_link table, that is where I set the property: https://github.com/apache/phoenix/pull/1575/files/de267ed7749ee7728e53fa45d159d4ffaa32984c#diff-eb1a64ec532ba7e19e95e6f7d6b4e2cfdc4c798b59d021fda3a8c4d80c49c349R239 -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
