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/06 23:55:22 UTC
[GitHub] [phoenix] gjacoby126 opened a new pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
gjacoby126 opened a new pull request #913:
URL: https://github.com/apache/phoenix/pull/913
----------------------------------------------------------------
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] gjacoby126 commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-745429251
Thanks for the reviews, @ChinmaySKulkarni @gokceni and @virajjasani !
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539742326
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
Review comment:
Actually the opposite -- when a local index is present I believe the WALEdits will have a mix of Cells from both the base table and the local index, because local indexes are stored within the actual table, just in a separate CF. So the later phases of change detection (that read the WALs) will have to filter out Cells that have the local index CF.
----------------------------------------------------------------
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] gjacoby126 commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-725058655
1. This feature requires a 4.16 client and a 4.16 server. The server code is intended to gracefully no-op and not annotate if the client hasn't provided anything.
2. The question would be how to store the list of tables to annotate, since so much of the logic is client-side where we don't have the server-side hbase-site.xml. It could be Yet Another PTable Attribute, but I'm unsure if it's worth the complexity -- wdyt? The conceptually cleanest way would be to annotate replicated tables and not annotate unreplicated ones, but replication scope is on the TableDescriptor, which we don't usually have access to client-side.
A critique I received offline to this PR from @priyankporwal suggested that annotating indexes might not be worth the storage cost, so we could also consider exempting indexes in the next draft (which is waiting on PHOENIX-6186 to populate the DDL timestamps)
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542574493
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
##########
@@ -2102,6 +2106,17 @@ private PTable createTableInternal(CreateTableStatement statement, byte[][] spli
}
}
+ Boolean isChangeDetectionEnabledProp =
+ (Boolean) TableProperty.CHANGE_DETECTION_ENABLED.getValue(tableProps);
+ if (isChangeDetectionEnabledProp != null) {
+ if (tableType != TABLE && tableType != VIEW) {
+ throw new SQLExceptionInfo.Builder(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY)
Review comment:
Done
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541363956
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
##########
@@ -50,11 +53,19 @@
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.PageFilter;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.ScannerContext;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatGlobalIndexChecker;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
Review comment:
Fixed -- lots were remnants from when we annotated indexes
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541382620
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
##########
@@ -1239,4 +1239,21 @@ public static boolean isDummy(List<Cell> result) {
Cell cell = result.get(0);
return CellUtil.matchingColumn(cell, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY);
}
+
+ public static void setWALAnnotationAttributes(PTable table, Scan scan) {
Review comment:
Added comments to the Utility methods in ScanUtil and WALAnnotationUtil to avoid duplication
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542573315
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java
##########
@@ -17,6 +17,7 @@
*/
package org.apache.phoenix.end2end;
+import org.apache.phoenix.util.TestDDLUtil;
Review comment:
Removed
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
##########
@@ -72,6 +72,7 @@
import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.QueryUtil;
import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestDDLUtil;
Review comment:
Removed
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r540433388
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
Review comment:
Ok, got it.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-707423341
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 4m 18s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 2 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 31s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 26m 3s | 4.x passed |
| +1 :green_heart: | compile | 1m 22s | 4.x passed |
| +1 :green_heart: | checkstyle | 4m 2s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 22s | 4.x passed |
| +0 :ok: | spotbugs | 0m 26s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 21s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 3m 54s | root in 4.x has 1011 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 40s | phoenix-core in 4.x has 957 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 23s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 23m 43s | the patch passed |
| +1 :green_heart: | compile | 1m 27s | the patch passed |
| +1 :green_heart: | cc | 1m 27s | the patch passed |
| +1 :green_heart: | javac | 1m 27s | the patch passed |
| -1 :x: | checkstyle | 4m 14s | root: The patch generated 308 new + 8142 unchanged - 61 fixed = 8450 total (was 8203) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| -1 :x: | whitespace | 0m 0s | The patch has 1 line(s) that end in whitespace. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply |
| +1 :green_heart: | xml | 0m 2s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 23s | the patch passed |
| -1 :x: | spotbugs | 3m 8s | phoenix-core generated 4 new + 956 unchanged - 1 fixed = 960 total (was 957) |
| -1 :x: | spotbugs | 4m 10s | root generated 4 new + 1010 unchanged - 1 fixed = 1014 total (was 1011) |
||| _ Other Tests _ |
| -1 :x: | unit | 114m 35s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 51s | The patch does not generate ASF License warnings. |
| | | 209m 17s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 124] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 719] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| FindBugs | module:root |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 124] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 719] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| Failed junit tests | phoenix.end2end.UpgradeIT |
| | phoenix.end2end.OrphanViewToolIT |
| 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-913/3/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux 2fb3ebe1bc30 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 | 4.x / acb2123 |
| 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-913/3/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| whitespace | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/3/artifact/yetus-general-check/output/whitespace-eol.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/3/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/3/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/3/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/3/testReport/ |
| Max. process+thread count | 5826 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/3/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 prototool=1.10.0-dev |
| 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] gjacoby126 commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-736887345
In this latest revision:
1. I added a new boolean flag, CHANGE_DETECTION_ENABLED to System.Catalog which is configured via property on table or view creation. It can be changed via ALTER. Adding it to an index will fail. Only tables and views with this flag set to true (it defaults false) will have their changes annotated into the WAL. Future JIRAs (such as PHOENIX-6227, and the main CDC code which will go in phoenix-connectors) will also use this flag.
2. Indexes are no longer annotated.
3. Shifted WALAnnotationIT to use the SchemaBuilder API introduced with Phoenix TTL
I believe the one remaining request left to do is @kadirozde 's suggestion to do a perf test. I will do this over the next couple of days.
@ChinmaySKulkarni , @kadirozde , fyi.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-704670166
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 6m 59s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 2 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 43s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 9m 16s | 4.x passed |
| +1 :green_heart: | compile | 1m 53s | 4.x passed |
| +1 :green_heart: | checkstyle | 3m 23s | 4.x passed |
| +1 :green_heart: | javadoc | 3m 7s | 4.x passed |
| +0 :ok: | spotbugs | 0m 35s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 30s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 28s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 5m 46s | root in 4.x has 1011 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 3m 29s | phoenix-core in 4.x has 957 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 28s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 5m 56s | the patch passed |
| +1 :green_heart: | compile | 1m 48s | the patch passed |
| +1 :green_heart: | cc | 1m 48s | the patch passed |
| +1 :green_heart: | javac | 1m 48s | the patch passed |
| -1 :x: | checkstyle | 3m 35s | root: The patch generated 272 new + 6145 unchanged - 41 fixed = 6417 total (was 6186) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| -1 :x: | whitespace | 0m 0s | The patch has 1 line(s) that end in whitespace. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply |
| +1 :green_heart: | xml | 0m 2s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 3m 5s | the patch passed |
| -1 :x: | spotbugs | 4m 0s | phoenix-core generated 4 new + 956 unchanged - 1 fixed = 960 total (was 957) |
| -1 :x: | spotbugs | 5m 29s | root generated 4 new + 1010 unchanged - 1 fixed = 1014 total (was 1011) |
||| _ Other Tests _ |
| -1 :x: | unit | 143m 30s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 56s | The patch does not generate ASF License warnings. |
| | | 214m 11s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 124] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 719] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| FindBugs | module:root |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 124] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 719] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| Failed junit tests | phoenix.end2end.ViewMetadataIT |
| 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-913/1/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux 989c2b3fb99f 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 | 4.x / 3008ca9 |
| 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-913/1/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| whitespace | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/1/artifact/yetus-general-check/output/whitespace-eol.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/1/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/1/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/1/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/1/testReport/ |
| Max. process+thread count | 5708 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/1/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.3 prototool=1.10.0-dev |
| 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] stoty commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-736036102
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 33s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 3 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 32s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 10m 53s | 4.x passed |
| +1 :green_heart: | compile | 1m 23s | 4.x passed |
| +1 :green_heart: | checkstyle | 9m 38s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 26s | 4.x passed |
| +0 :ok: | spotbugs | 0m 27s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 22s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 4m 9s | root in 4.x has 1004 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 59s | phoenix-core in 4.x has 950 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 25s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 5m 59s | the patch passed |
| +1 :green_heart: | compile | 1m 26s | the patch passed |
| +1 :green_heart: | cc | 1m 26s | the patch passed |
| +1 :green_heart: | javac | 1m 26s | the patch passed |
| -1 :x: | checkstyle | 9m 5s | root: The patch generated 496 new + 23127 unchanged - 152 fixed = 23623 total (was 23279) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 2s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 27s | the patch passed |
| -1 :x: | spotbugs | 3m 44s | phoenix-core generated 3 new + 950 unchanged - 0 fixed = 953 total (was 950) |
| -1 :x: | spotbugs | 5m 25s | root generated 3 new + 1004 unchanged - 0 fixed = 1007 total (was 1004) |
||| _ Other Tests _ |
| -1 :x: | unit | 132m 36s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 37s | The patch does not generate ASF License warnings. |
| | | 204m 21s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| Failed junit tests | phoenix.end2end.ViewTTLIT |
| 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-913/6/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux febe6ca7d32a 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 | 4.x / 6195621 |
| 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-913/6/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/6/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/6/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/6/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/6/testReport/ |
| Max. process+thread count | 6043 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/6/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] ChinmaySKulkarni commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539718201
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
##########
@@ -1239,4 +1239,21 @@ public static boolean isDummy(List<Cell> result) {
Cell cell = result.get(0);
return CellUtil.matchingColumn(cell, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY);
}
+
+ public static void setWALAnnotationAttributes(PTable table, Scan scan) {
Review comment:
@gjacoby126 Here is my understanding overall, please correct me if I'm wrong. There are 2 basic paths:
1. (Client-side delete and upsert-values) Client issues Puts/Deletes directly: This is handled in `MutationState. annotateMutationsWithMetadata()`
2. (Server-side delete and upsert-selects) Client issues scans, the server intercepts this and issues Put/Delete mutations based on the results read: This is what this method handles right? My understanding is we set the scan attributes in UpsertCompiler and DeleteCompiler and this is intercepted in `UngroupedAggregateRegionScanner` where we read the scan attribute and set it on the mutations.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541383107
##########
File path: phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/coprocessor/CompatGlobalIndexChecker.java
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.compat.hbase.coprocessor;
+
+import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
+
+public class CompatGlobalIndexChecker extends BaseRegionObserver {
+ //HBase 1.5+ has preWALAppend already declared in BaseRegionObserver, so this class is only
Review comment:
This particular file no longer exists, but I fixed some of these as I found them. The reason why is just that I usually don't type a space when I start a one-line comment, and when I find I need to make it multi-line the IDE fixes the spacing on subsequent lines but not the first one. :-)
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539644075
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java
##########
@@ -17,6 +17,7 @@
*/
package org.apache.phoenix.end2end;
+import org.apache.phoenix.util.TestDDLUtil;
Review comment:
nit: unused import
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
Review comment:
nit: static import `assertFalse()` like you've done for `assertNotNull()`
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
##########
@@ -247,9 +195,10 @@ public void testMultiTenantViewLocalIndex() throws Exception {
String indexName = "IND_" + generateUniqueName();
String fullTableName = SchemaUtil.getTableName(SCHEMA1, tableName);
String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName());
-
- createBaseTable(SCHEMA1, tableName, true, null, null, true);
- Connection conn = DriverManager.getConnection(getUrl());
+
+ Connection conn = getConnection();
Review comment:
Is this a connection leak?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
Review comment:
When you say "aren't supported", do you mean there should be no virtual table name corresponding to the local index in the WAL annotations for the base table? Can we add a test for this?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/WALAnnotationUtil.java
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.util;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+
+import java.util.Map;
+
+/**
+ * Utility functions shared between IndexRegionObserver and GlobalIndexChecker for annotating the
+ * HBase WAL with Phoenix-level metadata about mutations.
+ */
+public class WALAnnotationUtil {
Review comment:
Since this is specific to indexing, can we rename the class to reflect that?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
Review comment:
nit: static import `assertEquals()`
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
Review comment:
Isn't there a config that toggles client-side vs. server-side deletes? Just curious, will setting this config to `client-side` cause some of these tests to fail?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
Review comment:
nit: static import assertTrue()
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
Review comment:
nit: static import `fail()`
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
+ //(i.e, it generates the Mutations and then pushes them to server, rather than
+ // running a select query and deleting the mutations returned)
+ String deleteSql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ return table.getLastDDLTimestamp();
Review comment:
Can you please add a comment here for clarity to mention that the upsert/delete statements won't affect this timestamp and it reflects the time of creation of the table in this case (since there is no other ALTER statement)?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
Review comment:
Do we want to do some upserts and call `getEntriesForTable()` again at this point, just to ensure that entries exist now that change detection is enabled?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
Review comment:
When we expect 0 `numOccurences`, the logicalname and ddlTimestamp are not used right? Can we pass in null or modify the `assertAnnotation()` to make this clear?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
##########
@@ -278,10 +227,8 @@ public void testMultiTenantViewLocalIndex() throws Exception {
stmt.setInt(5, 400);
stmt.execute();
conn.commit();
-
- Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
- props.setProperty("TenantId", "10");
- Connection conn1 = DriverManager.getConnection(getUrl(), props);
+
+ Connection conn1 = getTenantConnection("10");
Review comment:
Is this a connection leak?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
+ //(i.e, it generates the Mutations and then pushes them to server, rather than
+ // running a select query and deleting the mutations returned)
+ String deleteSql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ return table.getLastDDLTimestamp();
+ }
+ }
+
+ private SchemaBuilder.TableOptions getTableOptions() {
+ SchemaBuilder.TableOptions tableOptions =
+ SchemaBuilder.TableOptions.withDefaults();
+ tableOptions.setImmutable(isImmutable);
+ tableOptions.setMultiTenant(isMultiTenant);
+ tableOptions.setChangeDetectionEnabled(true);
+ return tableOptions;
+ }
+
+ @Test
+ public void testUpsertSelectClientSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = getConnection()) {
+ SchemaBuilder baseBuilder = new SchemaBuilder(getUrl());
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ //upsert selecting from a different table will force processing to be client-side
+ baseBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " " +
+ "VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ String sql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " (OID, KP, COL1, COL2, COL3) SELECT * FROM " + baseBuilder.getEntityTableName();
+ conn.createStatement().execute(sql);
+ conn.commit();
+ int expectedAnnotations = 1;
+ verifyBaseAndTargetAnnotations(conn, baseBuilder, targetBuilder, expectedAnnotations);
+ }
+ }
+
+ private void verifyBaseAndTargetAnnotations(Connection conn, SchemaBuilder baseBuilder,
+ SchemaBuilder targetBuilder,
+ int expectedAnnotations) throws SQLException, IOException {
+ PTable baseTable = PhoenixRuntime.getTableNoCache(conn,
+ baseBuilder.getEntityTableName());
+ assertAnnotation(expectedAnnotations, baseBuilder.getPhysicalTableName(false), null,
+ baseBuilder.getTableOptions().getSchemaName(),
+ baseBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE,
+ baseTable.getLastDDLTimestamp());
+ PTable targetTable = PhoenixRuntime.getTableNoCache(conn,
+ targetBuilder.getEntityTableName());
+ assertAnnotation(expectedAnnotations, targetBuilder.getPhysicalTableName(false), null,
+ targetBuilder.getTableOptions().getSchemaName(), targetBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE, targetTable.getLastDDLTimestamp());
+ }
+
+ @Test
+ public void testUpsertSelectServerSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeFalse(isImmutable); //only mutable tables can be processed server-side
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + targetBuilder.getEntityTableName() + " " +
+ "VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ conn.setAutoCommit(true); //required for server side execution
+ clearAnnotations(TableName.valueOf(targetBuilder.getPhysicalTableName(false)));
+ String sql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " (OID, KP, COL1, COL2, COL3) SELECT * FROM " + targetBuilder.getEntityTableName();
+ conn.createStatement().execute(sql);
+ PTable table = PhoenixRuntime.getTableNoCache(conn, targetBuilder.getEntityTableName());
+ assertAnnotation(1, targetBuilder.getPhysicalTableName(false), null,
+ targetBuilder.getTableOptions().getSchemaName(),
+ targetBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE, table.getLastDDLTimestamp());
+ }
+
+ }
+
+ @Test
+ public void testGroupedUpsertSelect() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ //because we're inserting to a different table than we're selecting from, this should be
+ // processed client-side
+ SchemaBuilder baseBuilder = new SchemaBuilder(getUrl());
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ baseBuilder.withTableOptions(getTableOptions()).build();
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ String aggSql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " SELECT OID, KP, MAX(COL1), MIN(COL2), MAX(COL3) FROM " + baseBuilder.getEntityTableName() +
+ " GROUP BY OID, KP";
+ conn.createStatement().execute(aggSql);
+ conn.commit();
+ int expectedAnnotations = 1;
+ verifyBaseAndTargetAnnotations(conn, baseBuilder, targetBuilder, expectedAnnotations);
+ }
+ }
+
+ @Test
+ public void testRangeDeleteServerSide() throws Exception {
+ boolean isClientSide = false;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ private void testRangeDeleteHelper(boolean isClientSide) throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableOptions(getTableOptions()).build();
+ try (Connection conn = getConnection()) {
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityTableName() +
+ " VALUES ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ //Deleting by a partial PK to so that it executes a SELECT and then deletes the
+ // returned mutations
+ String sql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+
+ if (isClientSide) {
+ sql += " LIMIT 1";
+ }
+ conn.setAutoCommit(!isClientSide);
+ conn.createStatement().execute(sql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ assertAnnotation(2, table.getPhysicalName().getString(), null,
+ table.getSchemaName().getString(),
+ table.getTableName().getString(), PTableType.TABLE, table.getLastDDLTimestamp());
+ }
+
+ }
+
+ @Test
+ public void testRangeDeleteClientSide() throws Exception {
+ boolean isClientSide = true;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ @Test
+ public void testGlobalViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(builder, conn);
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityGlobalViewName()
+ + " VALUES" + " ('a', '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP +
+ "', '2', 'bc', '3', 'c')");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + builder.getEntityGlobalViewName() + " " +
+ "WHERE OID = 'a' AND KP = '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + "' " +
+ "and ID = 'c'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityGlobalViewName());
+ assertAnnotation(2, view.getPhysicalName().getString(), null,
+ view.getSchemaName().getString(),
+ view.getTableName().getString(), PTableType.VIEW, view.getLastDDLTimestamp());
+ }
+
+ }
+
+ private void createGlobalViewHelper(SchemaBuilder builder, Connection conn) throws Exception {
+ builder.withTableOptions(getTableOptions()).
+ withGlobalViewOptions(getGlobalViewOptions(builder)).build();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityGlobalViewName());
+ Assert.assertTrue("View does not have change detection enabled!",
+ view.isChangeDetectionEnabled());
+ }
+
+ private SchemaBuilder.GlobalViewOptions getGlobalViewOptions(SchemaBuilder builder) {
+ SchemaBuilder.GlobalViewOptions options = SchemaBuilder.GlobalViewOptions.withDefaults();
+ options.setChangeDetectionEnabled(true);
+ return options;
+ }
+
+ @Test
+ public void testTenantViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeTrue(isMultiTenant);
+ boolean createIndex = false;
+ tenantViewHelper(createIndex);
+ }
+
+ private void tenantViewHelper(boolean createIndex) throws Exception {
+ //create a base table, global view, and child tenant view, then insert / delete into the
+ // child tenant view. Make sure that the annotations use the tenant view name
+ String tenant = generateUniqueName();
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(builder, conn);
+ }
+ try (Connection conn = getTenantConnection(tenant)) {
+ SchemaBuilder.DataOptions dataOptions = builder.getDataOptions();
+ dataOptions.setTenantId(tenant);
+ if (createIndex) {
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).withTenantViewIndexDefaults().build();
+ } else {
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).build();
+ }
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).withTenantViewIndexDefaults().build();
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityTenantViewName()
+ + " VALUES" + " ('" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + "', '2', 'bc', " +
+ "'3', 'c', " + "'col4', 'col5', 'col6', 'd')");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + builder.getEntityTenantViewName() + " " +
+ "WHERE KP = '"+ PhoenixTestBuilder.DDLDefaults.DEFAULT_KP +
+ "' and COL1 = '2' AND ID = 'c' AND ZID = 'd'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTenantViewName());
+ assertAnnotation(2, view.getPhysicalName().getString(), tenant,
+ view.getSchemaName().getString(),
+ view.getTableName().getString(), PTableType.VIEW, view.getLastDDLTimestamp());
+ if (createIndex) {
+ assertAnnotation(0,
+ MetaDataUtil.getViewIndexPhysicalName(builder.getEntityTableName()),
+ tenant, view.getSchemaName().getString(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTenantViewIndexName()),
+ PTableType.INDEX,
+ view.getLastDDLTimestamp());
+ }
+ }
+
+ }
+
+ private SchemaBuilder.TenantViewOptions getTenantViewOptions(SchemaBuilder builder) {
+ SchemaBuilder.TenantViewOptions options = SchemaBuilder.TenantViewOptions.withDefaults();
+ options.setChangeDetectionEnabled(true);
+ return options;
+ }
+
+ @Test
+ public void testTenantViewUpsertWithIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeTrue(isMultiTenant);
+ tenantViewHelper(true);
+ }
+
+ private List<Map<String, byte[]>> getEntriesForTable(TableName tableName) throws IOException {
+ AnnotatedWALObserver c = getTestCoprocessor(tableName);
+ List<Map<String, byte[]>> entries = c.getWalAnnotationsByTable(tableName);
+ return entries != null ? entries : new ArrayList<Map<String, byte[]>>();
+ }
+
+ private AnnotatedWALObserver getTestCoprocessor(TableName tableName) throws IOException {
+ HRegionInfo info = getUtility().getHBaseCluster().getRegions(tableName).get(0).getRegionInfo();
+ WAL wal = getUtility().getHBaseCluster().getRegionServer(0).getWAL(info);
+ WALCoprocessorHost host = wal.getCoprocessorHost();
+ return (AnnotatedWALObserver) host.findCoprocessor(AnnotatedWALObserver.class.getName());
+ }
+
+ private void clearAnnotations(TableName tableName) throws IOException {
+ AnnotatedWALObserver observer = getTestCoprocessor(tableName);
+ observer.clearAnnotations();
+ }
+
+ private void assertAnnotation(int numOccurrences, String physicalTableName, String tenant,
+ String schemaName,
+ String logicalTableName,
+ PTableType tableType, long ddlTimestamp) throws IOException {
Review comment:
So the idea is that the WAL entry corresponding to an upsert/delete on an entity (table or view) will contain an annotation which has the `lastDDLTimestamp` of the entity and this can be used against a potential schema registry to find what was the schema of the entity at that point in time when the mutation was issued on it?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -682,6 +687,49 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
values.putAll(modifiedValues);
}
+ private void annotateMutationsWithMetadata(PTable table, List<Mutation> rowMutations) {
+ //only annotate if the change detection flag is on the table and HBase supports
+ // preWALAppend coprocs server-side
+ if (table == null || !table.isChangeDetectionEnabled()
+ || !HbaseCompatCapabilities.hasPreWALAppend()) {
+ return;
+ }
+ //annotate each mutation with enough metadata so that anyone interested can
+ // deterministically figure out exactly what Phoenix schema object created the mutation
+ // Server-side we can annotate the HBase WAL with these.
+ for (Mutation mutation : rowMutations) {
+ annotateMutationWithMetadata(table, mutation);
+ }
+
+ }
+
+ public static void annotateMutationWithMetadata(PTable table, Mutation mutation) {
+ if (mutation.getDurability() == Durability.SKIP_WAL) {
Review comment:
I think we need to do this check everywhere. Also, can this be moved to a relevant Util class since we'd want to potentially call this method in all places where annotation is required?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
##########
@@ -1257,7 +1261,11 @@ public ImmutableBytesPtr getEmptyKeyValueFamily() {
// If if there are no covered columns, we know it's our default name
return emptyKeyValueCFPtr;
}
-
+
+ public String getLogicalIndexName() {
+ return logicalIndexName;
Review comment:
Is this mainly for view indexes? For local indexes we aren't doing any annotation and for global indexes, the logical name is the name of PTable. Can you please clarify and/or add a comment about this?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
##########
@@ -1034,6 +1066,15 @@ private void removeBatchMutateContext(ObserverContext<RegionCoprocessorEnvironme
this.batchMutateContext.remove();
}
+ @Override
+ public void preWALAppend(ObserverContext<RegionCoprocessorEnvironment> c, WALKey key,
+ WALEdit edit) {
+ if (HbaseCompatCapabilities.hasPreWALAppend() && shouldWALAppend) {
Review comment:
I thought we weren't going to annotate indexes.
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
##########
@@ -50,11 +53,19 @@
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.PageFilter;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.hbase.regionserver.MiniBatchOperationInProgress;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.ScannerContext;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatGlobalIndexChecker;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
Review comment:
A lot of these imports seem to be unused
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -644,4 +651,33 @@ public boolean next(List<Cell> resultsToReturn) throws IOException {
public long getMaxResultSize() {
return scan.getMaxResultSize();
}
+
+ private void annotateDataMutations(UngroupedAggregateRegionObserver.MutationList mutationsList,
+ Scan scan) {
+ byte[] tenantId = null;
+ byte[] logicalTableName = null;
+ byte[] schemaName = null;
+ byte[] tableType = null;
+ byte[] ddlTimestamp = null;
+ tenantId =
+ scan.getAttribute(MutationState.MutationMetadataType.TENANT_ID.toString());
+ schemaName =
+ scan.getAttribute(MutationState.MutationMetadataType.SCHEMA_NAME.toString());
+ logicalTableName =
+ scan.getAttribute(MutationState.MutationMetadataType.LOGICAL_TABLE_NAME.toString());
+ tableType =
+ scan.getAttribute(MutationState.MutationMetadataType.TABLE_TYPE.toString());
+ ddlTimestamp = scan.getAttribute(MutationState.MutationMetadataType.TIMESTAMP.toString());
+
+ for (Mutation m : mutationsList) {
Review comment:
We should check WAL durability here as well right?
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/coprocessor/TaskMetaDataEndpointTest.java
##########
@@ -139,7 +140,12 @@ public RegionServerServices getRegionServerServices() {
public ConcurrentMap<String, Object> getSharedData() {
return null;
}
- };
+
+ @Override
Review comment:
nit: Fix indentation.
Also, what is this change for?
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java
##########
@@ -644,6 +646,9 @@ public void upsertRows(int startRowIndex, int numRows) throws Exception {
String entityTableName;
String entityGlobalViewName;
String entityTenantViewName;
+ String entityTableIndexName;
Review comment:
Can these variables be `private`?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1160,6 +1169,12 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp, long tableT
null : PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ Cell changeDetectionEnabledKv = tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
+ boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
Review comment:
If a new client modifies some table's CDE field, there won't be a problem for old clients interacting with the table right?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
##########
@@ -1239,4 +1239,21 @@ public static boolean isDummy(List<Cell> result) {
Cell cell = result.get(0);
return CellUtil.matchingColumn(cell, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY);
}
+
+ public static void setWALAnnotationAttributes(PTable table, Scan scan) {
Review comment:
@gjacoby126 Here is my understanding overall, please correct me if I'm wrong. There are 2 basic paths:
1. (Client-side delete) Client issues Puts/Deletes directly: This is handled in `MutationState. annotateMutationsWithMetadata()`
2. (Server-side delete and upsert-selects) Client issues scans, the server intercepts this and issues Put/Delete mutations based on the results read: This is what this method handles right? My understanding is we set the scan attributes in UpsertCompiler and DeleteCompiler and this is intercepted in `UngroupedAggregateRegionScanner` where we read the scan attribute and set it on the mutations.
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -674,6 +678,7 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
mutation.setAttribute(PhoenixIndexBuilder.ATOMIC_OP_ATTRIB, onDupKeyBytes);
}
}
+ annotateMutationsWithMetadata(table, rowMutations);
Review comment:
+1, there is no difference between the if and else as far as annotation goes right?
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java
##########
@@ -1230,6 +1285,12 @@ private String buildCreateGlobalViewStmt(String fullGlobalViewName, String fullT
.append((globalViewOptions.tableProps.isEmpty() ?
"" :
globalViewOptions.tableProps));
+ if (globalViewOptions.isChangeDetectionEnabled()) {
+ if (!globalViewOptions.tableProps.isEmpty()) {
+ statement.append(", ");
+ }
+ statement.append("CHANGE_DETECTION_ENABLED=true");
Review comment:
nit: Use a static constant representing CHANGE_DETECTION_ENABLED instead
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
##########
@@ -1239,4 +1239,21 @@ public static boolean isDummy(List<Cell> result) {
Cell cell = result.get(0);
return CellUtil.matchingColumn(cell, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY);
}
+
+ public static void setWALAnnotationAttributes(PTable table, Scan scan) {
Review comment:
Can we add comments based on this in the compiler and/or this method. Also a similar comment in MutationState would be helpful.
##########
File path: phoenix-hbase-compat-1.5.0/src/main/java/org/apache/phoenix/compat/hbase/coprocessor/CompatGlobalIndexChecker.java
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.compat.hbase.coprocessor;
+
+import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
+
+public class CompatGlobalIndexChecker extends BaseRegionObserver {
+ //HBase 1.5+ has preWALAppend already declared in BaseRegionObserver, so this class is only
Review comment:
Super nit: multi-line comments throughout the pr have no space for the first line and 1 space for subsequent ones. Maybe keep it the same for all lines, unless this is some convention I'm unaware of, in which case ignore :D
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -682,6 +687,49 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
values.putAll(modifiedValues);
}
+ private void annotateMutationsWithMetadata(PTable table, List<Mutation> rowMutations) {
+ //only annotate if the change detection flag is on the table and HBase supports
+ // preWALAppend coprocs server-side
+ if (table == null || !table.isChangeDetectionEnabled()
+ || !HbaseCompatCapabilities.hasPreWALAppend()) {
+ return;
+ }
+ //annotate each mutation with enough metadata so that anyone interested can
+ // deterministically figure out exactly what Phoenix schema object created the mutation
+ // Server-side we can annotate the HBase WAL with these.
+ for (Mutation mutation : rowMutations) {
+ annotateMutationWithMetadata(table, mutation);
+ }
+
+ }
+
+ public static void annotateMutationWithMetadata(PTable table, Mutation mutation) {
+ if (mutation.getDurability() == Durability.SKIP_WAL) {
Review comment:
Maybe `WALAnnotationUtil`?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
Review comment:
Even if the delete is issued as a select from the client and delete mutations are issued for those, we would still get the same mutations as if the client had directly issued DELETE mutations right? And then WAL annotations wouldn't change either in both scenarios right?
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r533790379
##########
File path: pom.xml
##########
@@ -1173,7 +1173,7 @@
</profile>
<!-- See BUILDING.md for profile selection -->
<profile>
- <id>phoenix-hbase-compat-1.3.0-default</id>
+ <id>phoenix-hbase-compat-1.5.0-default</id>
Review comment:
With 1.3 as the default, it's difficult to run the 1.5-specific tests like WALAnnotationIT in IntelliJ, and it means they won't get exercised in the automated test runs. FYI, @stoty .
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-734013444
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 4m 11s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 3 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 32s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 10m 44s | 4.x passed |
| +1 :green_heart: | compile | 1m 25s | 4.x passed |
| +1 :green_heart: | checkstyle | 10m 32s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 22s | 4.x passed |
| +0 :ok: | spotbugs | 0m 27s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 22s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 24s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 3m 59s | root in 4.x has 1004 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 38s | phoenix-core in 4.x has 950 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 24s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 5m 59s | the patch passed |
| +1 :green_heart: | compile | 1m 28s | the patch passed |
| +1 :green_heart: | cc | 1m 28s | the patch passed |
| +1 :green_heart: | javac | 1m 28s | the patch passed |
| -1 :x: | checkstyle | 10m 46s | root: The patch generated 541 new + 23086 unchanged - 193 fixed = 23627 total (was 23279) |
| +1 :green_heart: | prototool | 0m 1s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 2s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 26s | the patch passed |
| -1 :x: | spotbugs | 3m 11s | phoenix-core generated 5 new + 950 unchanged - 0 fixed = 955 total (was 950) |
| -1 :x: | spotbugs | 4m 12s | root generated 5 new + 1004 unchanged - 0 fixed = 1009 total (was 1004) |
||| _ Other Tests _ |
| -1 :x: | unit | 143m 37s | root in the patch failed. |
| +1 :green_heart: | asflicense | 0m 45s | The patch does not generate ASF License warnings. |
| | | 214m 46s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 126] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 126] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| 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-913/5/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux c23295b9be68 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 | 4.x / 7ac4dff |
| 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-913/5/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/5/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/5/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/5/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/5/testReport/ |
| Max. process+thread count | 5945 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/5/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] stoty commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-736953930
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 31s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 4 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 32s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 10m 57s | 4.x passed |
| +1 :green_heart: | compile | 1m 27s | 4.x passed |
| +1 :green_heart: | checkstyle | 10m 21s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 23s | 4.x passed |
| +0 :ok: | spotbugs | 0m 27s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 24s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 21s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 3m 58s | root in 4.x has 1004 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 42s | phoenix-core in 4.x has 950 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 24s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 6m 17s | the patch passed |
| +1 :green_heart: | compile | 1m 34s | the patch passed |
| +1 :green_heart: | cc | 1m 34s | the patch passed |
| +1 :green_heart: | javac | 1m 34s | the patch passed |
| -1 :x: | checkstyle | 10m 40s | root: The patch generated 537 new + 23086 unchanged - 193 fixed = 23623 total (was 23279) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 1s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 21s | the patch passed |
| -1 :x: | spotbugs | 3m 13s | phoenix-core generated 3 new + 950 unchanged - 0 fixed = 953 total (was 950) |
| -1 :x: | spotbugs | 4m 14s | root generated 3 new + 1004 unchanged - 0 fixed = 1007 total (was 1004) |
||| _ Other Tests _ |
| -1 :x: | unit | 140m 47s | root in the patch failed. |
| +1 :green_heart: | asflicense | 0m 43s | The patch does not generate ASF License warnings. |
| | | 208m 41s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| 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-913/7/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux de63ff85ea36 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 | 4.x / 18b9f76 |
| 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-913/7/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/7/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/7/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/7/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/7/testReport/ |
| Max. process+thread count | 6126 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/7/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] ChinmaySKulkarni commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r520944121
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java
##########
@@ -98,4 +99,13 @@ public void testQueryWithMultipleColumnFamiliesAndMultipleConditionsForImmutable
}
}
}
+
+ @Test
+ public void testImmutableTableCreation() throws Exception {
Review comment:
We already have immutable table creation in other tests in this class. Do we need this test?
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,520 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestDDLUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private TestDDLUtil ddlUtil;
+ private boolean isImmutable;
+ private boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ ddlUtil = new TestDDLUtil(false);
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<String, String>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ boolean createGlobalIndex = false;
+ upsertAndDeleteHelper(tableInfo, createGlobalIndex);
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getTableName(), PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ boolean createGlobalIndex = true;
+ upsertAndDeleteHelper(tableInfo, createGlobalIndex);
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getTableName(), PTableType.TABLE, minTimestamp, true);
+ assertAnnotation(2, tableInfo.getPhysicalGlobalIndexName(), null, tableInfo.getSchemaName(),
+ tableInfo.getIndexName(), PTableType.INDEX, minTimestamp, true);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private void upsertAndDeleteHelper(TestTableInfo tableInfo, boolean createGlobalIndex) throws SQLException {
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, tableInfo.getSchemaName(), tableInfo.getTableName(),
+ isMultiTenant, null, null, isImmutable);
+ if (createGlobalIndex) {
+ ddlUtil.createIndex(conn, tableInfo.getSchemaName(), tableInfo.getIndexName(),
+ tableInfo.getTableName(), "v1", false, false);
+ }
+ String upsertSql = "UPSERT INTO " + tableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
+ //(i.e, it generates the Mutations and then pushes them to server, rather than
+ // running a select query and deleting the mutations returned)
+ String deleteSql = "DELETE FROM " + tableInfo.getFullTableName() + " " +
+ "WHERE t_id = 'a' AND k1 = 'b'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ }
+ }
+
+ @Test
+ public void testUpsertSelectClientSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo baseTableInfo = new TestTableInfo();
+ TestTableInfo targetTableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ //upsert selecting from a different table will force processing to be client-side
+ ddlUtil.createBaseTable(conn, baseTableInfo.getSchemaName(), baseTableInfo.getTableName(),
+ isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + baseTableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ ddlUtil.createBaseTable(conn, targetTableInfo.getSchemaName(),
+ targetTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ String sql = "UPSERT INTO " + targetTableInfo.getFullTableName() +
+ " (t_id, k1, k2, v1, v2) SELECT * FROM " + baseTableInfo.getFullTableName();
+ conn.createStatement().execute(sql);
+ conn.commit();
+ }
+ assertAnnotation(1, baseTableInfo.getPhysicalTableName(), null,
+ baseTableInfo.getSchemaName(), baseTableInfo.getTableName(), PTableType.TABLE,
+ minTimestamp, true);
+ assertAnnotation(1, targetTableInfo.getPhysicalTableName(), null,
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testUpsertSelectServerSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeFalse(isImmutable); //only mutable tables can be processed server-side
+ TestTableInfo targetTableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, targetTableInfo.getSchemaName(),
+ targetTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + targetTableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ conn.setAutoCommit(true); //required for server side execution
+ clearAnnotations(TableName.valueOf(SchemaUtil.getPhysicalHBaseTableName(
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ false).getString()));
+ String sql = "UPSERT INTO " + targetTableInfo.getFullTableName() +
+ " (t_id, k1, k2, v1, v2) SELECT * FROM " + targetTableInfo.getFullTableName();
+ conn.createStatement().execute(sql);
+ }
+ assertAnnotation(1, targetTableInfo.getPhysicalTableName(), null,
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testGroupedUpsertSelect() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ //because we're inserting to a different table than we're selecting from, this should be
+ // processed client-side
+ TestTableInfo baseTableInfo = new TestTableInfo();
+ TestTableInfo targetTableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, baseTableInfo.getSchemaName(),
+ baseTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ ddlUtil.createBaseTable(conn, targetTableInfo.getSchemaName(),
+ targetTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + baseTableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ String aggSql = "UPSERT INTO " + targetTableInfo.getFullTableName() +
+ " SELECT t_id, k1, k2, MIN(v1), AVG(v2) FROM " + baseTableInfo.getFullTableName() +
+ " GROUP BY t_id, k1, k2";
+ conn.createStatement().execute(aggSql);
+ conn.commit();
+ }
+ assertAnnotation(1, baseTableInfo.getPhysicalTableName(), null,
+ baseTableInfo.getSchemaName(), baseTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ assertAnnotation(1, targetTableInfo.getPhysicalTableName(), null,
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testRangeDeleteServerSide() throws Exception {
+ boolean isClientSide = false;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ private void testRangeDeleteHelper(boolean isClientSide) throws SQLException, IOException {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, tableInfo.getSchemaName(), tableInfo.getTableName(),
+ isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + tableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ //Deleting by a partial PK to so that it executes a SELECT and then deletes the
+ // returned mutations
+ String sql = "DELETE FROM " + tableInfo.getFullTableName() + " " +
+ "WHERE t_id = 'a' AND k1 = 'b'";
+
+ if (isClientSide) {
+ sql += " LIMIT 1";
+ }
+ conn.setAutoCommit(!isClientSide);
+ conn.createStatement().execute(sql);
+ conn.commit();
+ }
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getTableName(), PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testRangeDeleteClientSide() throws Exception {
+ boolean isClientSide = true;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ @Test
+ public void testGlobalViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(tableInfo, conn);
+ conn.createStatement().execute("UPSERT INTO " + tableInfo.getFullViewName()
+ + " VALUES" + " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + tableInfo.getFullViewName() + " " +
+ "WHERE t_id = 'a' AND k1 = 'b' and k2 = 2";
+ conn.createStatement().execute(deleteSql);
+ conn.commit(); }
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getViewName(), PTableType.VIEW, minTimestamp, true);
+ }
+ private void createGlobalViewHelper(TestTableInfo tableInfo, Connection conn) throws SQLException {
Review comment:
nit: add a newline
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/util/TestDDLUtil.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.util;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class TestDDLUtil {
Review comment:
I might be wrong here, but don't we already have a class like this introduced by @jpisaac for creating test tables, indices, etc. and test data too?
##########
File path: pom.xml
##########
@@ -1173,7 +1173,7 @@
</profile>
<!-- See BUILDING.md for profile selection -->
<profile>
- <id>phoenix-hbase-compat-1.3.0-default</id>
+ <id>phoenix-hbase-compat-1.5.0-default</id>
Review comment:
Why did we change this?
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542791748
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java
##########
@@ -2192,6 +2192,21 @@ public Builder setColumnNameBytes(
*/
com.google.protobuf.ByteString
getParentTableTypeBytes();
+
+ // optional string logicalIndexName = 25;
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ boolean hasLogicalIndexName();
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ java.lang.String getLogicalIndexName();
Review comment:
@gokceni Correct, should be populated for all indexes.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542572942
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -674,6 +678,7 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
mutation.setAttribute(PhoenixIndexBuilder.ATOMIC_OP_ATTRIB, onDupKeyBytes);
}
}
+ annotateMutationsWithMetadata(table, rowMutations);
Review comment:
Done.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r533789672
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/util/TestDDLUtil.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.util;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class TestDDLUtil {
Review comment:
Switched WALAnnotationIT to use @jpisaac 's SchemaBuilder class (and enhanced it a bit to fill in a couple feature gaps)
----------------------------------------------------------------
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] gjacoby126 commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-744599398
@gokceni , @ChinmaySKulkarni , @virajjasani , I believe I have addressed all outstanding comments (and also pushed up a fix for an NPE in ViewIndexIT the last test run found.) Could you please give it another look? Thanks!
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541345592
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
##########
@@ -400,7 +400,6 @@ protected boolean isRegionObserverFor(Scan scan) {
* Used for an aggregate query in which the key order does not necessarily match the group by
* key order. In this case, we must collect all distinct groups within a region into a map,
* aggregating as we go.
- * @param limit TODO
Review comment:
Removed the params from the Javadoc as they were Javadoc errors.
----------------------------------------------------------------
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 a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539235012
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -644,4 +651,33 @@ public boolean next(List<Cell> resultsToReturn) throws IOException {
public long getMaxResultSize() {
return scan.getMaxResultSize();
}
+
+ private void annotateDataMutations(UngroupedAggregateRegionObserver.MutationList mutationsList,
+ Scan scan) {
+ byte[] tenantId = null;
Review comment:
nit: we are assigning these variables representing MutationMetadataType twice (`null` and `scan.getAttribute()`), should we assign all of them just once by removing null assignments?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -64,6 +64,7 @@
import org.apache.phoenix.cache.GlobalCache;
import org.apache.phoenix.cache.TenantCache;
import org.apache.phoenix.exception.DataExceedsCapacityException;
+import org.apache.phoenix.execute.MutationState;
Review comment:
nit: redundant?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
##########
@@ -2102,6 +2106,17 @@ private PTable createTableInternal(CreateTableStatement statement, byte[][] spli
}
}
+ Boolean isChangeDetectionEnabledProp =
+ (Boolean) TableProperty.CHANGE_DETECTION_ENABLED.getValue(tableProps);
+ if (isChangeDetectionEnabledProp != null) {
+ if (tableType != TABLE && tableType != VIEW) {
+ throw new SQLExceptionInfo.Builder(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY)
Review comment:
If possible, we can refactor this validation in a small util method and it can be used by both workflows: createTable/createIndex and addColumn/alterIndex?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -682,6 +687,49 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
values.putAll(modifiedValues);
}
+ public static void annotateMutationsWithMetadata(PTable table, List<Mutation> rowMutations) {
+ //only annotate if the change detection flag is on the table and HBase supports
+ // preWALAppend coprocs server-side
+ if (table == null || !table.isChangeDetectionEnabled()
+ || !HbaseCompatCapabilities.hasPreWALAppend()) {
+ return;
+ }
+ //annotate each mutation with enough metadata so that anyone interested can
+ // deterministically figure out exactly what Phoenix schema object created the mutation
+ // Server-side we can annotate the HBase WAL with these.
+ for (Mutation mutation : rowMutations) {
+ annotateMutationWithMetadata(table, mutation);
+ }
+
+ }
+
+ public static void annotateMutationWithMetadata(PTable table, Mutation mutation) {
Review comment:
nit: we can keep both util methods `private`?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/WALAnnotationUtil.java
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.util;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+
+import java.util.Map;
+
+/**
+ * Utility functions shared between IndexRegionObserver and GlobalIndexChecker for annotating the
+ * HBase WAL with Phoenix-level metadata about mutations.
+ */
+public class WALAnnotationUtil {
+
+ public static void appendMutationAttributesToWALKey(WALKey key,
+ IndexRegionObserver.BatchMutateContext context) {
+ if (context != null && context.getOriginalMutations().size() > 0) {
+ Mutation firstMutation = context.getOriginalMutations().get(0);
+ Map<String, byte[]> attrMap = firstMutation.getAttributesMap();
+ for (MutationState.MutationMetadataType metadataType :
+ MutationState.MutationMetadataType.values()) {
+ String metadataTypeKey = metadataType.toString();
+ if (attrMap.containsKey(metadataTypeKey)) {
+ CompatIndexRegionObserver.appendToWALKey(key, metadataTypeKey,
Review comment:
`appendToWALKey()` is public only in 1.5 compact class but not in 1.3/1.4 compact classes, without which this could cause compilation issue while running against 1.3/1.4.
##########
File path: phoenix-hbase-compat-1.3.0/src/main/java/org/apache/phoenix/compat/hbase/coprocessor/CompatIndexRegionObserver.java
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.compat.hbase.coprocessor;
+
+import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.wal.WALKey;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CompatIndexRegionObserver extends BaseRegionObserver {
+ public static String PHOENIX_APPEND_METADATA_TO_WAL = "phoenix.append.metadata.to.wal";
+ public static boolean DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL = false;
Review comment:
nit: should we avoid defining constants in Compat classes?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1160,6 +1169,12 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp, long tableT
null : PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ Cell changeDetectionEnabledKv = tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
+ boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
Review comment:
In case of old client - new server case, `changeDetectionEnabledKv` will be null right?
----------------------------------------------------------------
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 edited a comment on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
virajjasani edited a comment on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-744607510
@gjacoby126 btw for the past couple of days, all precommit PR builds for 4.x (that I came across) are timing out and precommit Jira builds for 4.x patch are passing by ~1/4 probability (that I am aware of) so you might also want to upload 4.x patch to Jira to trigger 4.x precommit Jira build.
----------------------------------------------------------------
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 pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-725042677
@gjacoby126 Some high-level questions:
1. For interactions with old clients, do we still get these WAL annotations (for ex: 4.16 server + 4.14 client) or do we only get this after clients are upgraded?
2. Is it worth-while to maintain a whitelist for tables/views/indices where we may not want to enable this?
----------------------------------------------------------------
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] gokceni commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gokceni commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-745426803
@gjacoby126 +1 Thanks!
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541367097
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/WALAnnotationUtil.java
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.util;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+
+import java.util.Map;
+
+/**
+ * Utility functions shared between IndexRegionObserver and GlobalIndexChecker for annotating the
+ * HBase WAL with Phoenix-level metadata about mutations.
+ */
+public class WALAnnotationUtil {
Review comment:
It's not specific to indexing.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541364685
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
##########
@@ -1257,7 +1261,11 @@ public ImmutableBytesPtr getEmptyKeyValueFamily() {
// If if there are no covered columns, we know it's our default name
return emptyKeyValueCFPtr;
}
-
+
+ public String getLogicalIndexName() {
+ return logicalIndexName;
Review comment:
Correct. Will add a comment.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541349997
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -609,6 +613,9 @@ public boolean next(List<Cell> resultsToReturn) throws IOException {
} while (hasMore && (EnvironmentEdgeManager.currentTimeMillis() - startTime) < pageSizeInMs);
if (!mutations.isEmpty()) {
+ if (isDelete || isUpsert) {
+ annotateDataMutations(mutations, scan);
+ }
Review comment:
Done
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-738563704
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 30s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 4 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 32s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 10m 40s | 4.x passed |
| +1 :green_heart: | compile | 1m 22s | 4.x passed |
| +1 :green_heart: | checkstyle | 10m 33s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 24s | 4.x passed |
| +0 :ok: | spotbugs | 0m 26s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 24s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 21s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 3m 59s | root in 4.x has 1004 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 39s | phoenix-core in 4.x has 950 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 24s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 6m 4s | the patch passed |
| +1 :green_heart: | compile | 1m 28s | the patch passed |
| +1 :green_heart: | cc | 1m 28s | the patch passed |
| +1 :green_heart: | javac | 1m 28s | the patch passed |
| -1 :x: | checkstyle | 10m 51s | root: The patch generated 496 new + 23126 unchanged - 152 fixed = 23622 total (was 23278) |
| +1 :green_heart: | prototool | 0m 1s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 1s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 23s | the patch passed |
| -1 :x: | spotbugs | 3m 11s | phoenix-core generated 3 new + 950 unchanged - 0 fixed = 953 total (was 950) |
| -1 :x: | spotbugs | 4m 13s | root generated 3 new + 1004 unchanged - 0 fixed = 1007 total (was 1004) |
||| _ Other Tests _ |
| -1 :x: | unit | 294m 10s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 31s | The patch does not generate ASF License warnings. |
| | | 365m 36s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| Failed junit tests | phoenix.end2end.PermissionNSEnabledWithCustomAccessControllerIT |
| | phoenix.end2end.ViewMetadataIT |
| | phoenix.end2end.join.SubqueryIT |
| 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-913/8/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux 505cd6e9f51a 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 | 4.x / 5e70f76 |
| 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-913/8/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/8/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/8/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/8/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/8/testReport/ |
| Max. process+thread count | 6034 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/8/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] gjacoby126 commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-736968410
The test run is odd -- looks like phoenix-core passed but then there was an error in building or shading phoenix-client? I can't reproduce locally -- mvn clean install -DskipTests passes for me.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541350748
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -644,4 +651,33 @@ public boolean next(List<Cell> resultsToReturn) throws IOException {
public long getMaxResultSize() {
return scan.getMaxResultSize();
}
+
+ private void annotateDataMutations(UngroupedAggregateRegionObserver.MutationList mutationsList,
+ Scan scan) {
+ byte[] tenantId = null;
Review comment:
Done
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r533790439
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,520 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestDDLUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private TestDDLUtil ddlUtil;
+ private boolean isImmutable;
+ private boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ ddlUtil = new TestDDLUtil(false);
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<String, String>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ boolean createGlobalIndex = false;
+ upsertAndDeleteHelper(tableInfo, createGlobalIndex);
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getTableName(), PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ boolean createGlobalIndex = true;
+ upsertAndDeleteHelper(tableInfo, createGlobalIndex);
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getTableName(), PTableType.TABLE, minTimestamp, true);
+ assertAnnotation(2, tableInfo.getPhysicalGlobalIndexName(), null, tableInfo.getSchemaName(),
+ tableInfo.getIndexName(), PTableType.INDEX, minTimestamp, true);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private void upsertAndDeleteHelper(TestTableInfo tableInfo, boolean createGlobalIndex) throws SQLException {
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, tableInfo.getSchemaName(), tableInfo.getTableName(),
+ isMultiTenant, null, null, isImmutable);
+ if (createGlobalIndex) {
+ ddlUtil.createIndex(conn, tableInfo.getSchemaName(), tableInfo.getIndexName(),
+ tableInfo.getTableName(), "v1", false, false);
+ }
+ String upsertSql = "UPSERT INTO " + tableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
+ //(i.e, it generates the Mutations and then pushes them to server, rather than
+ // running a select query and deleting the mutations returned)
+ String deleteSql = "DELETE FROM " + tableInfo.getFullTableName() + " " +
+ "WHERE t_id = 'a' AND k1 = 'b'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ }
+ }
+
+ @Test
+ public void testUpsertSelectClientSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo baseTableInfo = new TestTableInfo();
+ TestTableInfo targetTableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ //upsert selecting from a different table will force processing to be client-side
+ ddlUtil.createBaseTable(conn, baseTableInfo.getSchemaName(), baseTableInfo.getTableName(),
+ isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + baseTableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ ddlUtil.createBaseTable(conn, targetTableInfo.getSchemaName(),
+ targetTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ String sql = "UPSERT INTO " + targetTableInfo.getFullTableName() +
+ " (t_id, k1, k2, v1, v2) SELECT * FROM " + baseTableInfo.getFullTableName();
+ conn.createStatement().execute(sql);
+ conn.commit();
+ }
+ assertAnnotation(1, baseTableInfo.getPhysicalTableName(), null,
+ baseTableInfo.getSchemaName(), baseTableInfo.getTableName(), PTableType.TABLE,
+ minTimestamp, true);
+ assertAnnotation(1, targetTableInfo.getPhysicalTableName(), null,
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testUpsertSelectServerSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeFalse(isImmutable); //only mutable tables can be processed server-side
+ TestTableInfo targetTableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, targetTableInfo.getSchemaName(),
+ targetTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + targetTableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ conn.setAutoCommit(true); //required for server side execution
+ clearAnnotations(TableName.valueOf(SchemaUtil.getPhysicalHBaseTableName(
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ false).getString()));
+ String sql = "UPSERT INTO " + targetTableInfo.getFullTableName() +
+ " (t_id, k1, k2, v1, v2) SELECT * FROM " + targetTableInfo.getFullTableName();
+ conn.createStatement().execute(sql);
+ }
+ assertAnnotation(1, targetTableInfo.getPhysicalTableName(), null,
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testGroupedUpsertSelect() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ //because we're inserting to a different table than we're selecting from, this should be
+ // processed client-side
+ TestTableInfo baseTableInfo = new TestTableInfo();
+ TestTableInfo targetTableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, baseTableInfo.getSchemaName(),
+ baseTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ ddlUtil.createBaseTable(conn, targetTableInfo.getSchemaName(),
+ targetTableInfo.getTableName(), isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + baseTableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ String aggSql = "UPSERT INTO " + targetTableInfo.getFullTableName() +
+ " SELECT t_id, k1, k2, MIN(v1), AVG(v2) FROM " + baseTableInfo.getFullTableName() +
+ " GROUP BY t_id, k1, k2";
+ conn.createStatement().execute(aggSql);
+ conn.commit();
+ }
+ assertAnnotation(1, baseTableInfo.getPhysicalTableName(), null,
+ baseTableInfo.getSchemaName(), baseTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ assertAnnotation(1, targetTableInfo.getPhysicalTableName(), null,
+ targetTableInfo.getSchemaName(), targetTableInfo.getTableName(),
+ PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testRangeDeleteServerSide() throws Exception {
+ boolean isClientSide = false;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ private void testRangeDeleteHelper(boolean isClientSide) throws SQLException, IOException {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ ddlUtil.createBaseTable(conn, tableInfo.getSchemaName(), tableInfo.getTableName(),
+ isMultiTenant, null, null, isImmutable);
+ conn.createStatement().execute("UPSERT INTO " + tableInfo.getFullTableName() + " VALUES" +
+ " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ //Deleting by a partial PK to so that it executes a SELECT and then deletes the
+ // returned mutations
+ String sql = "DELETE FROM " + tableInfo.getFullTableName() + " " +
+ "WHERE t_id = 'a' AND k1 = 'b'";
+
+ if (isClientSide) {
+ sql += " LIMIT 1";
+ }
+ conn.setAutoCommit(!isClientSide);
+ conn.createStatement().execute(sql);
+ conn.commit();
+ }
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getTableName(), PTableType.TABLE, minTimestamp, true);
+ }
+
+ @Test
+ public void testRangeDeleteClientSide() throws Exception {
+ boolean isClientSide = true;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ @Test
+ public void testGlobalViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ TestTableInfo tableInfo = new TestTableInfo();
+ long minTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(tableInfo, conn);
+ conn.createStatement().execute("UPSERT INTO " + tableInfo.getFullViewName()
+ + " VALUES" + " ('a', 'b', 2, 'bc', 3)");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + tableInfo.getFullViewName() + " " +
+ "WHERE t_id = 'a' AND k1 = 'b' and k2 = 2";
+ conn.createStatement().execute(deleteSql);
+ conn.commit(); }
+ assertAnnotation(2, tableInfo.getPhysicalTableName(), null, tableInfo.getSchemaName(),
+ tableInfo.getViewName(), PTableType.VIEW, minTimestamp, true);
+ }
+ private void createGlobalViewHelper(TestTableInfo tableInfo, Connection conn) throws SQLException {
Review comment:
Done.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541362722
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -682,6 +687,49 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
values.putAll(modifiedValues);
}
+ private void annotateMutationsWithMetadata(PTable table, List<Mutation> rowMutations) {
+ //only annotate if the change detection flag is on the table and HBase supports
+ // preWALAppend coprocs server-side
+ if (table == null || !table.isChangeDetectionEnabled()
+ || !HbaseCompatCapabilities.hasPreWALAppend()) {
+ return;
+ }
+ //annotate each mutation with enough metadata so that anyone interested can
+ // deterministically figure out exactly what Phoenix schema object created the mutation
+ // Server-side we can annotate the HBase WAL with these.
+ for (Mutation mutation : rowMutations) {
+ annotateMutationWithMetadata(table, mutation);
+ }
+
+ }
+
+ public static void annotateMutationWithMetadata(PTable table, Mutation mutation) {
Review comment:
Consolidated in WALAnnotationUtil as @ChinmaySKulkarni suggested.
----------------------------------------------------------------
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] gokceni commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gokceni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542579426
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java
##########
@@ -2192,6 +2192,21 @@ public Builder setColumnNameBytes(
*/
com.google.protobuf.ByteString
getParentTableTypeBytes();
+
+ // optional string logicalIndexName = 25;
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ boolean hasLogicalIndexName();
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ java.lang.String getLogicalIndexName();
Review comment:
@gjacoby126 thanks for addressing my comments. There is just this question remaining.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-742188973
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 1m 10s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 4 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 31s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 12m 3s | 4.x passed |
| +1 :green_heart: | compile | 1m 36s | 4.x passed |
| +1 :green_heart: | checkstyle | 6m 24s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 47s | 4.x passed |
| +0 :ok: | spotbugs | 0m 29s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 25s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 4m 43s | root in 4.x has 1005 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 3m 11s | phoenix-core in 4.x has 951 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 25s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 7m 22s | the patch passed |
| +1 :green_heart: | compile | 2m 4s | the patch passed |
| +1 :green_heart: | cc | 2m 4s | the patch passed |
| +1 :green_heart: | javac | 2m 4s | the patch passed |
| -1 :x: | checkstyle | 8m 10s | root: The patch generated 506 new + 23134 unchanged - 191 fixed = 23640 total (was 23325) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 2s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 3m 5s | the patch passed |
| -1 :x: | spotbugs | 3m 59s | phoenix-core generated 2 new + 951 unchanged - 0 fixed = 953 total (was 951) |
| -1 :x: | spotbugs | 5m 32s | root generated 2 new + 1005 unchanged - 0 fixed = 1007 total (was 1005) |
||| _ Other Tests _ |
| -1 :x: | unit | 198m 10s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 8s | The patch does not generate ASF License warnings. |
| | | 271m 24s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| Failed junit tests | phoenix.end2end.IndexExtendedIT |
| | phoenix.util.IndexScrutinyIT |
| | phoenix.end2end.IndexScrutinyToolIT |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/11/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux b75c8bf09267 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 | 4.x / 432474e |
| 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-913/11/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/11/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/11/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/11/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/11/testReport/ |
| Max. process+thread count | 5876 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/11/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] stoty commented on pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-741008245
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 30s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 4 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 33s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 11m 14s | 4.x passed |
| +1 :green_heart: | compile | 1m 22s | 4.x passed |
| +1 :green_heart: | checkstyle | 8m 47s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 20s | 4.x passed |
| +0 :ok: | spotbugs | 0m 29s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 24s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 21s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 4m 4s | root in 4.x has 1004 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 43s | phoenix-core in 4.x has 950 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 27s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 5m 59s | the patch passed |
| +1 :green_heart: | compile | 1m 28s | the patch passed |
| +1 :green_heart: | cc | 1m 28s | the patch passed |
| +1 :green_heart: | javac | 1m 28s | the patch passed |
| -1 :x: | checkstyle | 9m 1s | root: The patch generated 536 new + 23080 unchanged - 192 fixed = 23616 total (was 23272) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 1s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 24s | the patch passed |
| -1 :x: | spotbugs | 3m 14s | phoenix-core generated 3 new + 950 unchanged - 0 fixed = 953 total (was 950) |
| -1 :x: | spotbugs | 4m 17s | root generated 3 new + 1004 unchanged - 0 fixed = 1007 total (was 1004) |
||| _ Other Tests _ |
| -1 :x: | unit | 148m 12s | root in the patch failed. |
| +1 :green_heart: | asflicense | 0m 47s | The patch does not generate ASF License warnings. |
| | | 212m 54s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| 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-913/9/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux f4f92db0025f 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 | 4.x / 1261c3f |
| 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-913/9/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/9/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/9/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/9/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/9/testReport/ |
| Max. process+thread count | 5776 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/9/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539637405
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1160,6 +1169,12 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp, long tableT
null : PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ Cell changeDetectionEnabledKv = tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
+ boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
Review comment:
So long as some other client hasn't set CHANGE_DETECTION_ENABLED=true on the table via an ALTER statement.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-707205451
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 0s | Docker mode activated. |
| -1 :x: | docker | 2m 30s | Docker failed to build yetus/phoenix:955047a0b. |
| Subsystem | Report/Notes |
|----------:|:-------------|
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/2/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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539639738
##########
File path: phoenix-hbase-compat-1.3.0/src/main/java/org/apache/phoenix/compat/hbase/coprocessor/CompatIndexRegionObserver.java
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.compat.hbase.coprocessor;
+
+import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.wal.WALKey;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CompatIndexRegionObserver extends BaseRegionObserver {
+ public static String PHOENIX_APPEND_METADATA_TO_WAL = "phoenix.append.metadata.to.wal";
+ public static boolean DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL = false;
Review comment:
These aren't used, will remove.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
ChinmaySKulkarni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539689792
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
Review comment:
Even if the delete is issued as a select from the client and delete mutations are issued for those, we would still get the same mutations as if the client had directly issued DELETE mutations right? And then WAL annotations wouldn't change either in both scenarios right? If so, why are we preferring one over the other in the test?
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-731496674
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 3m 27s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 3 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 42s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 12m 54s | 4.x passed |
| +1 :green_heart: | compile | 1m 32s | 4.x passed |
| +1 :green_heart: | checkstyle | 2m 53s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 23s | 4.x passed |
| +0 :ok: | spotbugs | 0m 26s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 4m 25s | root in 4.x has 1004 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 57s | phoenix-core in 4.x has 950 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 27s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 6m 57s | the patch passed |
| +1 :green_heart: | compile | 1m 36s | the patch passed |
| +1 :green_heart: | cc | 1m 36s | the patch passed |
| +1 :green_heart: | javac | 1m 36s | the patch passed |
| -1 :x: | checkstyle | 3m 0s | root: The patch generated 330 new + 8319 unchanged - 76 fixed = 8649 total (was 8395) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 1s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 28s | the patch passed |
| -1 :x: | spotbugs | 3m 29s | phoenix-core generated 4 new + 950 unchanged - 0 fixed = 954 total (was 950) |
| -1 :x: | spotbugs | 4m 36s | root generated 4 new + 1004 unchanged - 0 fixed = 1008 total (was 1004) |
||| _ Other Tests _ |
| -1 :x: | unit | 195m 56s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 22s | The patch does not generate ASF License warnings. |
| | | 259m 36s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 126] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| FindBugs | module:root |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.DEFAULT_PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 126] |
| | org.apache.phoenix.hbase.index.IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL isn't final but should be At IndexRegionObserver.java:be At IndexRegionObserver.java:[line 125] |
| | Load of known null value in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:in org.apache.phoenix.hbase.index.IndexRegionObserver.prepareIndexMutations(IndexRegionObserver$BatchMutateContext, List, long) At IndexRegionObserver.java:[line 800] |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| Failed junit tests | phoenix.end2end.index.ViewIndexIT |
| 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-913/4/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux 88e7da627350 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 | 4.x / e57fcc8 |
| 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-913/4/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/4/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/4/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/4/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/4/testReport/ |
| Max. process+thread count | 6080 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/4/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542572032
##########
File path: phoenix-core/src/test/java/org/apache/phoenix/coprocessor/TaskMetaDataEndpointTest.java
##########
@@ -139,7 +140,12 @@ public RegionServerServices getRegionServerServices() {
public ConcurrentMap<String, Object> getSharedData() {
return null;
}
- };
+
+ @Override
Review comment:
A previous version of this patch had PHOENIX-6155 but not its addendum that fixed compilation on certain HBase versions. The current version has the addendum and so this file shouldn't be altered in this patch anymore.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r542791748
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java
##########
@@ -2192,6 +2192,21 @@ public Builder setColumnNameBytes(
*/
com.google.protobuf.ByteString
getParentTableTypeBytes();
+
+ // optional string logicalIndexName = 25;
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ boolean hasLogicalIndexName();
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ java.lang.String getLogicalIndexName();
Review comment:
Correct, should be populated for all indexes.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539739591
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
Review comment:
We could, but isn't that covered by all the other tests?
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541362377
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -682,6 +687,49 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
values.putAll(modifiedValues);
}
+ public static void annotateMutationsWithMetadata(PTable table, List<Mutation> rowMutations) {
+ //only annotate if the change detection flag is on the table and HBase supports
+ // preWALAppend coprocs server-side
+ if (table == null || !table.isChangeDetectionEnabled()
+ || !HbaseCompatCapabilities.hasPreWALAppend()) {
+ return;
+ }
+ //annotate each mutation with enough metadata so that anyone interested can
+ // deterministically figure out exactly what Phoenix schema object created the mutation
+ // Server-side we can annotate the HBase WAL with these.
+ for (Mutation mutation : rowMutations) {
+ annotateMutationWithMetadata(table, mutation);
+ }
+
+ }
+
+ public static void annotateMutationWithMetadata(PTable table, Mutation mutation) {
Review comment:
Switched to private
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539739219
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
Review comment:
The annotation happens in different code paths depending on whether the delete gets executed client side (where it happens in MutationState) or server side (where it happens in the coproc), so I have tests for both to make sure that both work properly.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
virajjasani commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-744607510
@gjacoby126 btw for the past couple of days, all precommit PR builds (that I came across) are timing out and precommit Jira builds for 4.x patch are passing by ~1/4 probability (that I am aware of) so you might also want to upload 4.x patch to Jira to trigger 4.x precommit Jira build.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541346794
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
##########
@@ -1160,6 +1169,12 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp, long tableT
null : PLong.INSTANCE.getCodec().decodeLong(lastDDLTimestampKv.getValueArray(),
lastDDLTimestampKv.getValueOffset(), SortOrder.getDefault());
+ Cell changeDetectionEnabledKv = tableKeyValues[CHANGE_DETECTION_ENABLED_INDEX];
+ boolean isChangeDetectionEnabled = changeDetectionEnabledKv != null
Review comment:
Since it's an optional field in the protobuf and the old client won't even know to deserialize it I don't think it would cause a problem.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541364364
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/index/GlobalIndexChecker.java
##########
@@ -93,10 +106,11 @@
* the verified version that is masked by the unverified version(s).
*
*/
-public class GlobalIndexChecker extends BaseRegionObserver {
+public class GlobalIndexChecker extends CompatGlobalIndexChecker {
Review comment:
We don't need CompatGlobalIndexChecker now that we don't annotate indexes so I removed it
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539642721
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/WALAnnotationUtil.java
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.util;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+
+import java.util.Map;
+
+/**
+ * Utility functions shared between IndexRegionObserver and GlobalIndexChecker for annotating the
+ * HBase WAL with Phoenix-level metadata about mutations.
+ */
+public class WALAnnotationUtil {
+
+ public static void appendMutationAttributesToWALKey(WALKey key,
+ IndexRegionObserver.BatchMutateContext context) {
+ if (context != null && context.getOriginalMutations().size() > 0) {
+ Mutation firstMutation = context.getOriginalMutations().get(0);
+ Map<String, byte[]> attrMap = firstMutation.getAttributesMap();
+ for (MutationState.MutationMetadataType metadataType :
+ MutationState.MutationMetadataType.values()) {
+ String metadataTypeKey = metadataType.toString();
+ if (attrMap.containsKey(metadataTypeKey)) {
+ CompatIndexRegionObserver.appendToWALKey(key, metadataTypeKey,
Review comment:
Oops, thanks for the catch.
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539739771
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
+ //(i.e, it generates the Mutations and then pushes them to server, rather than
+ // running a select query and deleting the mutations returned)
+ String deleteSql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ return table.getLastDDLTimestamp();
+ }
+ }
+
+ private SchemaBuilder.TableOptions getTableOptions() {
+ SchemaBuilder.TableOptions tableOptions =
+ SchemaBuilder.TableOptions.withDefaults();
+ tableOptions.setImmutable(isImmutable);
+ tableOptions.setMultiTenant(isMultiTenant);
+ tableOptions.setChangeDetectionEnabled(true);
+ return tableOptions;
+ }
+
+ @Test
+ public void testUpsertSelectClientSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = getConnection()) {
+ SchemaBuilder baseBuilder = new SchemaBuilder(getUrl());
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ //upsert selecting from a different table will force processing to be client-side
+ baseBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " " +
+ "VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ String sql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " (OID, KP, COL1, COL2, COL3) SELECT * FROM " + baseBuilder.getEntityTableName();
+ conn.createStatement().execute(sql);
+ conn.commit();
+ int expectedAnnotations = 1;
+ verifyBaseAndTargetAnnotations(conn, baseBuilder, targetBuilder, expectedAnnotations);
+ }
+ }
+
+ private void verifyBaseAndTargetAnnotations(Connection conn, SchemaBuilder baseBuilder,
+ SchemaBuilder targetBuilder,
+ int expectedAnnotations) throws SQLException, IOException {
+ PTable baseTable = PhoenixRuntime.getTableNoCache(conn,
+ baseBuilder.getEntityTableName());
+ assertAnnotation(expectedAnnotations, baseBuilder.getPhysicalTableName(false), null,
+ baseBuilder.getTableOptions().getSchemaName(),
+ baseBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE,
+ baseTable.getLastDDLTimestamp());
+ PTable targetTable = PhoenixRuntime.getTableNoCache(conn,
+ targetBuilder.getEntityTableName());
+ assertAnnotation(expectedAnnotations, targetBuilder.getPhysicalTableName(false), null,
+ targetBuilder.getTableOptions().getSchemaName(), targetBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE, targetTable.getLastDDLTimestamp());
+ }
+
+ @Test
+ public void testUpsertSelectServerSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeFalse(isImmutable); //only mutable tables can be processed server-side
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + targetBuilder.getEntityTableName() + " " +
+ "VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ conn.setAutoCommit(true); //required for server side execution
+ clearAnnotations(TableName.valueOf(targetBuilder.getPhysicalTableName(false)));
+ String sql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " (OID, KP, COL1, COL2, COL3) SELECT * FROM " + targetBuilder.getEntityTableName();
+ conn.createStatement().execute(sql);
+ PTable table = PhoenixRuntime.getTableNoCache(conn, targetBuilder.getEntityTableName());
+ assertAnnotation(1, targetBuilder.getPhysicalTableName(false), null,
+ targetBuilder.getTableOptions().getSchemaName(),
+ targetBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE, table.getLastDDLTimestamp());
+ }
+
+ }
+
+ @Test
+ public void testGroupedUpsertSelect() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ //because we're inserting to a different table than we're selecting from, this should be
+ // processed client-side
+ SchemaBuilder baseBuilder = new SchemaBuilder(getUrl());
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ baseBuilder.withTableOptions(getTableOptions()).build();
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ String aggSql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " SELECT OID, KP, MAX(COL1), MIN(COL2), MAX(COL3) FROM " + baseBuilder.getEntityTableName() +
+ " GROUP BY OID, KP";
+ conn.createStatement().execute(aggSql);
+ conn.commit();
+ int expectedAnnotations = 1;
+ verifyBaseAndTargetAnnotations(conn, baseBuilder, targetBuilder, expectedAnnotations);
+ }
+ }
+
+ @Test
+ public void testRangeDeleteServerSide() throws Exception {
+ boolean isClientSide = false;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ private void testRangeDeleteHelper(boolean isClientSide) throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableOptions(getTableOptions()).build();
+ try (Connection conn = getConnection()) {
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityTableName() +
+ " VALUES ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ //Deleting by a partial PK to so that it executes a SELECT and then deletes the
+ // returned mutations
+ String sql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+
+ if (isClientSide) {
+ sql += " LIMIT 1";
+ }
+ conn.setAutoCommit(!isClientSide);
+ conn.createStatement().execute(sql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ assertAnnotation(2, table.getPhysicalName().getString(), null,
+ table.getSchemaName().getString(),
+ table.getTableName().getString(), PTableType.TABLE, table.getLastDDLTimestamp());
+ }
+
+ }
+
+ @Test
+ public void testRangeDeleteClientSide() throws Exception {
+ boolean isClientSide = true;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ @Test
+ public void testGlobalViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(builder, conn);
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityGlobalViewName()
+ + " VALUES" + " ('a', '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP +
+ "', '2', 'bc', '3', 'c')");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + builder.getEntityGlobalViewName() + " " +
+ "WHERE OID = 'a' AND KP = '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + "' " +
+ "and ID = 'c'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityGlobalViewName());
+ assertAnnotation(2, view.getPhysicalName().getString(), null,
+ view.getSchemaName().getString(),
+ view.getTableName().getString(), PTableType.VIEW, view.getLastDDLTimestamp());
+ }
+
+ }
+
+ private void createGlobalViewHelper(SchemaBuilder builder, Connection conn) throws Exception {
+ builder.withTableOptions(getTableOptions()).
+ withGlobalViewOptions(getGlobalViewOptions(builder)).build();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityGlobalViewName());
+ Assert.assertTrue("View does not have change detection enabled!",
+ view.isChangeDetectionEnabled());
+ }
+
+ private SchemaBuilder.GlobalViewOptions getGlobalViewOptions(SchemaBuilder builder) {
+ SchemaBuilder.GlobalViewOptions options = SchemaBuilder.GlobalViewOptions.withDefaults();
+ options.setChangeDetectionEnabled(true);
+ return options;
+ }
+
+ @Test
+ public void testTenantViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeTrue(isMultiTenant);
+ boolean createIndex = false;
+ tenantViewHelper(createIndex);
+ }
+
+ private void tenantViewHelper(boolean createIndex) throws Exception {
+ //create a base table, global view, and child tenant view, then insert / delete into the
+ // child tenant view. Make sure that the annotations use the tenant view name
+ String tenant = generateUniqueName();
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(builder, conn);
+ }
+ try (Connection conn = getTenantConnection(tenant)) {
+ SchemaBuilder.DataOptions dataOptions = builder.getDataOptions();
+ dataOptions.setTenantId(tenant);
+ if (createIndex) {
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).withTenantViewIndexDefaults().build();
+ } else {
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).build();
+ }
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).withTenantViewIndexDefaults().build();
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityTenantViewName()
+ + " VALUES" + " ('" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + "', '2', 'bc', " +
+ "'3', 'c', " + "'col4', 'col5', 'col6', 'd')");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + builder.getEntityTenantViewName() + " " +
+ "WHERE KP = '"+ PhoenixTestBuilder.DDLDefaults.DEFAULT_KP +
+ "' and COL1 = '2' AND ID = 'c' AND ZID = 'd'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTenantViewName());
+ assertAnnotation(2, view.getPhysicalName().getString(), tenant,
+ view.getSchemaName().getString(),
+ view.getTableName().getString(), PTableType.VIEW, view.getLastDDLTimestamp());
+ if (createIndex) {
+ assertAnnotation(0,
+ MetaDataUtil.getViewIndexPhysicalName(builder.getEntityTableName()),
+ tenant, view.getSchemaName().getString(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTenantViewIndexName()),
+ PTableType.INDEX,
+ view.getLastDDLTimestamp());
+ }
+ }
+
+ }
+
+ private SchemaBuilder.TenantViewOptions getTenantViewOptions(SchemaBuilder builder) {
+ SchemaBuilder.TenantViewOptions options = SchemaBuilder.TenantViewOptions.withDefaults();
+ options.setChangeDetectionEnabled(true);
+ return options;
+ }
+
+ @Test
+ public void testTenantViewUpsertWithIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeTrue(isMultiTenant);
+ tenantViewHelper(true);
+ }
+
+ private List<Map<String, byte[]>> getEntriesForTable(TableName tableName) throws IOException {
+ AnnotatedWALObserver c = getTestCoprocessor(tableName);
+ List<Map<String, byte[]>> entries = c.getWalAnnotationsByTable(tableName);
+ return entries != null ? entries : new ArrayList<Map<String, byte[]>>();
+ }
+
+ private AnnotatedWALObserver getTestCoprocessor(TableName tableName) throws IOException {
+ HRegionInfo info = getUtility().getHBaseCluster().getRegions(tableName).get(0).getRegionInfo();
+ WAL wal = getUtility().getHBaseCluster().getRegionServer(0).getWAL(info);
+ WALCoprocessorHost host = wal.getCoprocessorHost();
+ return (AnnotatedWALObserver) host.findCoprocessor(AnnotatedWALObserver.class.getName());
+ }
+
+ private void clearAnnotations(TableName tableName) throws IOException {
+ AnnotatedWALObserver observer = getTestCoprocessor(tableName);
+ observer.clearAnnotations();
+ }
+
+ private void assertAnnotation(int numOccurrences, String physicalTableName, String tenant,
+ String schemaName,
+ String logicalTableName,
+ PTableType tableType, long ddlTimestamp) throws IOException {
Review comment:
Correct.
----------------------------------------------------------------
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 a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r543322994
##########
File path: pom.xml
##########
@@ -1173,7 +1173,7 @@
</profile>
<!-- See BUILDING.md for profile selection -->
<profile>
- <id>phoenix-hbase-compat-1.3.0-default</id>
+ <id>phoenix-hbase-compat-1.5.0-default</id>
Review comment:
Since 4.x multibranch keep running all tests with all supported versions including 1.5, pom.xml changes will be reverted before merging this PR?
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539740063
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java
##########
@@ -0,0 +1,550 @@
+/*
+ * 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.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.coprocessor.BaseWALObserver;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.wal.WALCoprocessorHost;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
+import org.junit.Assume;
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+@Category(NeedsOwnMiniClusterTest.class)
+public class WALAnnotationIT extends BaseUniqueNamesOwnClusterIT {
+ private final boolean isImmutable;
+ private final boolean isMultiTenant;
+
+ // name is used by failsafe as file name in reports
+ @Parameterized.Parameters(name = "WALAnnotationIT_isImmutable={0}_isMultiTenant={1}")
+ public static synchronized Collection<Object[]> data() {
+ return Arrays.asList(new Object[]{true, true}, new Object[]{true, false},
+ new Object[]{false, true}, new Object[]{false, false});
+ }
+
+ public WALAnnotationIT(boolean isImmutable, boolean isMultiTenant) {
+ this.isImmutable = isImmutable;
+ this.isMultiTenant = isMultiTenant;
+ }
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = new HashMap<>(2);
+ props.put("hbase.coprocessor.wal.classes",
+ AnnotatedWALObserver.class.getName());
+ props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true");
+ props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Test
+ public void testSimpleUpsertAndDelete() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = false;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ }
+
+ @Test
+ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+ tableOptions.setChangeDetectionEnabled(false);
+ builder.withTableOptions(tableOptions).build();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it shouldn't be!",
+ table.isChangeDetectionEnabled());
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')";
+ conn.createStatement().execute(upsertSql);
+ List<Map<String, byte[]>> entries =
+ getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ //now flip to TRUE so we can test disabling it
+ String enableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(enableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change detection is disabled when it should be enabled!",
+ table.isChangeDetectionEnabled());
+ //set to FALSE
+ String disableSql =
+ "ALTER TABLE " + builder.getEntityTableName() +
+ " SET " + CHANGE_DETECTION_ENABLED + "=FALSE";
+ conn.createStatement().execute(disableSql);
+ table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertFalse("Change detection is enabled when it should be disabled!",
+ table.isChangeDetectionEnabled());
+ //now upsert again
+ conn.createStatement().execute(upsertSql);
+ //check that we still didn't annotate anything
+ entries = getEntriesForTable(TableName.valueOf(builder.getPhysicalTableName(false)));
+ Assert.assertEquals(0, entries.size());
+ }
+ }
+
+ @Test
+ public void testCantSetChangeDetectionOnIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableDefaults().build();
+ try {
+ String badIndexSql =
+ "CREATE INDEX IDX_SHOULD_FAIL" + " ON " + builder.getEntityTableName() +
+ "(COL1) "
+ + CHANGE_DETECTION_ENABLED + "=TRUE";
+ conn.createStatement().execute(badIndexSql);
+ Assert.fail("Didn't throw a SQLException for setting change detection on an " +
+ "index at create time!");
+ } catch (SQLException se) {
+ TestUtil.assertSqlExceptionCode(
+ SQLExceptionCode.CHANGE_DETECTION_SUPPORTED_FOR_TABLES_AND_VIEWS_ONLY, se);
+ }
+ }
+ }
+
+ @Test
+ public void testUpsertAndDeleteWithGlobalIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ boolean createGlobalIndex = true;
+ long ddlTimestamp = upsertAndDeleteHelper(builder, createGlobalIndex);
+ assertAnnotation(2, builder.getPhysicalTableName(false), null,
+ builder.getTableOptions().getSchemaName(),
+ builder.getDataOptions().getTableName(), PTableType.TABLE, ddlTimestamp);
+ assertAnnotation(0, builder.getPhysicalTableIndexName(false),
+ null, builder.getTableOptions().getSchemaName(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTableIndexName()),
+ PTableType.INDEX,
+ ddlTimestamp);
+ }
+
+ //Note that local secondary indexes aren't supported because they go in the same WALEdit as the
+ // "base" table data they index.
+
+ private long upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception {
+ try (Connection conn = getConnection()) {
+ SchemaBuilder.TableOptions tableOptions = getTableOptions();
+
+ if (createGlobalIndex) {
+ builder.withTableOptions(tableOptions).withTableIndexDefaults().build();
+ } else {
+ builder.withTableOptions(tableOptions).build();
+ }
+
+ String upsertSql = "UPSERT INTO " + builder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', 'c')";
+ conn.createStatement().execute(upsertSql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ Assert.assertTrue("Change Detection Enabled is false!",
+ table.isChangeDetectionEnabled());
+ //Deleting by entire PK gets executed as more like an UPSERT VALUES than an UPSERT SELECT
+ //(i.e, it generates the Mutations and then pushes them to server, rather than
+ // running a select query and deleting the mutations returned)
+ String deleteSql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ return table.getLastDDLTimestamp();
+ }
+ }
+
+ private SchemaBuilder.TableOptions getTableOptions() {
+ SchemaBuilder.TableOptions tableOptions =
+ SchemaBuilder.TableOptions.withDefaults();
+ tableOptions.setImmutable(isImmutable);
+ tableOptions.setMultiTenant(isMultiTenant);
+ tableOptions.setChangeDetectionEnabled(true);
+ return tableOptions;
+ }
+
+ @Test
+ public void testUpsertSelectClientSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ try (Connection conn = getConnection()) {
+ SchemaBuilder baseBuilder = new SchemaBuilder(getUrl());
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ //upsert selecting from a different table will force processing to be client-side
+ baseBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " " +
+ "VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ String sql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " (OID, KP, COL1, COL2, COL3) SELECT * FROM " + baseBuilder.getEntityTableName();
+ conn.createStatement().execute(sql);
+ conn.commit();
+ int expectedAnnotations = 1;
+ verifyBaseAndTargetAnnotations(conn, baseBuilder, targetBuilder, expectedAnnotations);
+ }
+ }
+
+ private void verifyBaseAndTargetAnnotations(Connection conn, SchemaBuilder baseBuilder,
+ SchemaBuilder targetBuilder,
+ int expectedAnnotations) throws SQLException, IOException {
+ PTable baseTable = PhoenixRuntime.getTableNoCache(conn,
+ baseBuilder.getEntityTableName());
+ assertAnnotation(expectedAnnotations, baseBuilder.getPhysicalTableName(false), null,
+ baseBuilder.getTableOptions().getSchemaName(),
+ baseBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE,
+ baseTable.getLastDDLTimestamp());
+ PTable targetTable = PhoenixRuntime.getTableNoCache(conn,
+ targetBuilder.getEntityTableName());
+ assertAnnotation(expectedAnnotations, targetBuilder.getPhysicalTableName(false), null,
+ targetBuilder.getTableOptions().getSchemaName(), targetBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE, targetTable.getLastDDLTimestamp());
+ }
+
+ @Test
+ public void testUpsertSelectServerSide() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeFalse(isImmutable); //only mutable tables can be processed server-side
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + targetBuilder.getEntityTableName() + " " +
+ "VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ conn.setAutoCommit(true); //required for server side execution
+ clearAnnotations(TableName.valueOf(targetBuilder.getPhysicalTableName(false)));
+ String sql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " (OID, KP, COL1, COL2, COL3) SELECT * FROM " + targetBuilder.getEntityTableName();
+ conn.createStatement().execute(sql);
+ PTable table = PhoenixRuntime.getTableNoCache(conn, targetBuilder.getEntityTableName());
+ assertAnnotation(1, targetBuilder.getPhysicalTableName(false), null,
+ targetBuilder.getTableOptions().getSchemaName(),
+ targetBuilder.getDataOptions().getTableName(),
+ PTableType.TABLE, table.getLastDDLTimestamp());
+ }
+
+ }
+
+ @Test
+ public void testGroupedUpsertSelect() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ //because we're inserting to a different table than we're selecting from, this should be
+ // processed client-side
+ SchemaBuilder baseBuilder = new SchemaBuilder(getUrl());
+ SchemaBuilder targetBuilder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ baseBuilder.withTableOptions(getTableOptions()).build();
+ targetBuilder.withTableOptions(getTableOptions()).build();
+ conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " VALUES" +
+ " ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ String aggSql = "UPSERT INTO " + targetBuilder.getEntityTableName() +
+ " SELECT OID, KP, MAX(COL1), MIN(COL2), MAX(COL3) FROM " + baseBuilder.getEntityTableName() +
+ " GROUP BY OID, KP";
+ conn.createStatement().execute(aggSql);
+ conn.commit();
+ int expectedAnnotations = 1;
+ verifyBaseAndTargetAnnotations(conn, baseBuilder, targetBuilder, expectedAnnotations);
+ }
+ }
+
+ @Test
+ public void testRangeDeleteServerSide() throws Exception {
+ boolean isClientSide = false;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ private void testRangeDeleteHelper(boolean isClientSide) throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ builder.withTableOptions(getTableOptions()).build();
+ try (Connection conn = getConnection()) {
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityTableName() +
+ " VALUES ('a', 'b', '2', 'bc', '3')");
+ conn.commit();
+ //Deleting by a partial PK to so that it executes a SELECT and then deletes the
+ // returned mutations
+ String sql = "DELETE FROM " + builder.getEntityTableName() + " " +
+ "WHERE OID = 'a' AND KP = 'b'";
+
+ if (isClientSide) {
+ sql += " LIMIT 1";
+ }
+ conn.setAutoCommit(!isClientSide);
+ conn.createStatement().execute(sql);
+ conn.commit();
+ PTable table = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTableName());
+ assertAnnotation(2, table.getPhysicalName().getString(), null,
+ table.getSchemaName().getString(),
+ table.getTableName().getString(), PTableType.TABLE, table.getLastDDLTimestamp());
+ }
+
+ }
+
+ @Test
+ public void testRangeDeleteClientSide() throws Exception {
+ boolean isClientSide = true;
+ testRangeDeleteHelper(isClientSide);
+ }
+
+ @Test
+ public void testGlobalViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(builder, conn);
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityGlobalViewName()
+ + " VALUES" + " ('a', '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP +
+ "', '2', 'bc', '3', 'c')");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + builder.getEntityGlobalViewName() + " " +
+ "WHERE OID = 'a' AND KP = '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + "' " +
+ "and ID = 'c'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityGlobalViewName());
+ assertAnnotation(2, view.getPhysicalName().getString(), null,
+ view.getSchemaName().getString(),
+ view.getTableName().getString(), PTableType.VIEW, view.getLastDDLTimestamp());
+ }
+
+ }
+
+ private void createGlobalViewHelper(SchemaBuilder builder, Connection conn) throws Exception {
+ builder.withTableOptions(getTableOptions()).
+ withGlobalViewOptions(getGlobalViewOptions(builder)).build();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityGlobalViewName());
+ Assert.assertTrue("View does not have change detection enabled!",
+ view.isChangeDetectionEnabled());
+ }
+
+ private SchemaBuilder.GlobalViewOptions getGlobalViewOptions(SchemaBuilder builder) {
+ SchemaBuilder.GlobalViewOptions options = SchemaBuilder.GlobalViewOptions.withDefaults();
+ options.setChangeDetectionEnabled(true);
+ return options;
+ }
+
+ @Test
+ public void testTenantViewUpsert() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeTrue(isMultiTenant);
+ boolean createIndex = false;
+ tenantViewHelper(createIndex);
+ }
+
+ private void tenantViewHelper(boolean createIndex) throws Exception {
+ //create a base table, global view, and child tenant view, then insert / delete into the
+ // child tenant view. Make sure that the annotations use the tenant view name
+ String tenant = generateUniqueName();
+ SchemaBuilder builder = new SchemaBuilder(getUrl());
+ try (Connection conn = getConnection()) {
+ createGlobalViewHelper(builder, conn);
+ }
+ try (Connection conn = getTenantConnection(tenant)) {
+ SchemaBuilder.DataOptions dataOptions = builder.getDataOptions();
+ dataOptions.setTenantId(tenant);
+ if (createIndex) {
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).withTenantViewIndexDefaults().build();
+ } else {
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).build();
+ }
+ builder.withTenantViewOptions(getTenantViewOptions(builder)).
+ withDataOptions(dataOptions).withTenantViewIndexDefaults().build();
+ conn.createStatement().execute("UPSERT INTO " + builder.getEntityTenantViewName()
+ + " VALUES" + " ('" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + "', '2', 'bc', " +
+ "'3', 'c', " + "'col4', 'col5', 'col6', 'd')");
+ conn.commit();
+ String deleteSql = "DELETE FROM " + builder.getEntityTenantViewName() + " " +
+ "WHERE KP = '"+ PhoenixTestBuilder.DDLDefaults.DEFAULT_KP +
+ "' and COL1 = '2' AND ID = 'c' AND ZID = 'd'";
+ conn.createStatement().execute(deleteSql);
+ conn.commit();
+ PTable view = PhoenixRuntime.getTableNoCache(conn, builder.getEntityTenantViewName());
+ assertAnnotation(2, view.getPhysicalName().getString(), tenant,
+ view.getSchemaName().getString(),
+ view.getTableName().getString(), PTableType.VIEW, view.getLastDDLTimestamp());
+ if (createIndex) {
+ assertAnnotation(0,
+ MetaDataUtil.getViewIndexPhysicalName(builder.getEntityTableName()),
+ tenant, view.getSchemaName().getString(),
+ SchemaUtil.getTableNameFromFullName(builder.getEntityTenantViewIndexName()),
+ PTableType.INDEX,
+ view.getLastDDLTimestamp());
+ }
+ }
+
+ }
+
+ private SchemaBuilder.TenantViewOptions getTenantViewOptions(SchemaBuilder builder) {
+ SchemaBuilder.TenantViewOptions options = SchemaBuilder.TenantViewOptions.withDefaults();
+ options.setChangeDetectionEnabled(true);
+ return options;
+ }
+
+ @Test
+ public void testTenantViewUpsertWithIndex() throws Exception {
+ Assume.assumeTrue(HbaseCompatCapabilities.hasPreWALAppend());
+ Assume.assumeTrue(isMultiTenant);
+ tenantViewHelper(true);
+ }
+
+ private List<Map<String, byte[]>> getEntriesForTable(TableName tableName) throws IOException {
+ AnnotatedWALObserver c = getTestCoprocessor(tableName);
+ List<Map<String, byte[]>> entries = c.getWalAnnotationsByTable(tableName);
+ return entries != null ? entries : new ArrayList<Map<String, byte[]>>();
+ }
+
+ private AnnotatedWALObserver getTestCoprocessor(TableName tableName) throws IOException {
+ HRegionInfo info = getUtility().getHBaseCluster().getRegions(tableName).get(0).getRegionInfo();
+ WAL wal = getUtility().getHBaseCluster().getRegionServer(0).getWAL(info);
+ WALCoprocessorHost host = wal.getCoprocessorHost();
+ return (AnnotatedWALObserver) host.findCoprocessor(AnnotatedWALObserver.class.getName());
+ }
+
+ private void clearAnnotations(TableName tableName) throws IOException {
+ AnnotatedWALObserver observer = getTestCoprocessor(tableName);
+ observer.clearAnnotations();
+ }
+
+ private void assertAnnotation(int numOccurrences, String physicalTableName, String tenant,
+ String schemaName,
+ String logicalTableName,
+ PTableType tableType, long ddlTimestamp) throws IOException {
Review comment:
The part that does that will be contributed to phoenix-connectors, and @bharathv is currently developing it.
----------------------------------------------------------------
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] gokceni commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gokceni commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539564620
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java
##########
@@ -72,6 +72,7 @@
import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.QueryUtil;
import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestDDLUtil;
Review comment:
ditto
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java
##########
@@ -17,6 +17,7 @@
*/
package org.apache.phoenix.end2end;
+import org.apache.phoenix.util.TestDDLUtil;
Review comment:
nit: is the import necessary? Seems like the only change on this file is this import
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
##########
@@ -400,7 +400,6 @@ protected boolean isRegionObserverFor(Scan scan) {
* Used for an aggregate query in which the key order does not necessarily match the group by
* key order. In this case, we must collect all distinct groups within a region into a map,
* aggregating as we go.
- * @param limit TODO
Review comment:
TODO seems to be dropped but not implemented?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
##########
@@ -73,6 +73,7 @@
import org.apache.hadoop.io.WritableUtils;
import org.apache.phoenix.coprocessor.generated.PTableProtos;
import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.MutationState;
Review comment:
nit: lonely import
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -609,6 +613,9 @@ public boolean next(List<Cell> resultsToReturn) throws IOException {
} while (hasMore && (EnvironmentEdgeManager.currentTimeMillis() - startTime) < pageSizeInMs);
if (!mutations.isEmpty()) {
+ if (isDelete || isUpsert) {
+ annotateDataMutations(mutations, scan);
+ }
Review comment:
It would be nice to refactor this perhaps to a new method? Lines 596 to 602 is same as 616 to 622
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -682,6 +687,49 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
values.putAll(modifiedValues);
}
+ private void annotateMutationsWithMetadata(PTable table, List<Mutation> rowMutations) {
+ //only annotate if the change detection flag is on the table and HBase supports
+ // preWALAppend coprocs server-side
+ if (table == null || !table.isChangeDetectionEnabled()
+ || !HbaseCompatCapabilities.hasPreWALAppend()) {
+ return;
+ }
+ //annotate each mutation with enough metadata so that anyone interested can
+ // deterministically figure out exactly what Phoenix schema object created the mutation
+ // Server-side we can annotate the HBase WAL with these.
+ for (Mutation mutation : rowMutations) {
+ annotateMutationWithMetadata(table, mutation);
+ }
+
+ }
+
+ public static void annotateMutationWithMetadata(PTable table, Mutation mutation) {
Review comment:
Actually why not use the this method in the Ungroupped..Scanner in that for loop that goes over mutations? Also mutation durability was not checked there I think
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/generated/ServerCachingProtos.java
##########
@@ -2192,6 +2192,21 @@ public Builder setColumnNameBytes(
*/
com.google.protobuf.ByteString
getParentTableTypeBytes();
+
+ // optional string logicalIndexName = 25;
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ boolean hasLogicalIndexName();
+ /**
+ * <code>optional string logicalIndexName = 25;</code>
+ */
+ java.lang.String getLogicalIndexName();
Review comment:
Would this be populated for both view indexes and regular indexes and local indexes?
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
##########
@@ -674,6 +678,7 @@ private void generateMutations(final TableRef tableRef, final long mutationTimes
mutation.setAttribute(PhoenixIndexBuilder.ATOMIC_OP_ATTRIB, onDupKeyBytes);
}
}
+ annotateMutationsWithMetadata(table, rowMutations);
Review comment:
perhaps move this to line 684? (out of if else?)
----------------------------------------------------------------
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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539742976
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
##########
@@ -1034,6 +1066,15 @@ private void removeBatchMutateContext(ObserverContext<RegionCoprocessorEnvironme
this.batchMutateContext.remove();
}
+ @Override
+ public void preWALAppend(ObserverContext<RegionCoprocessorEnvironment> c, WALKey key,
+ WALEdit edit) {
+ if (HbaseCompatCapabilities.hasPreWALAppend() && shouldWALAppend) {
Review comment:
Despite the name, IndexRegionObserver is actually the coproc that lives on _base tables_, not indexes. (GlobalIndexChecker is the index coproc)
----------------------------------------------------------------
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 a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
virajjasani commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r539466637
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/WALAnnotationUtil.java
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.util;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.wal.WALKey;
+import org.apache.phoenix.compat.hbase.coprocessor.CompatIndexRegionObserver;
+import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.hbase.index.IndexRegionObserver;
+
+import java.util.Map;
+
+/**
+ * Utility functions shared between IndexRegionObserver and GlobalIndexChecker for annotating the
+ * HBase WAL with Phoenix-level metadata about mutations.
+ */
+public class WALAnnotationUtil {
+
+ public static void appendMutationAttributesToWALKey(WALKey key,
+ IndexRegionObserver.BatchMutateContext context) {
+ if (context != null && context.getOriginalMutations().size() > 0) {
+ Mutation firstMutation = context.getOriginalMutations().get(0);
+ Map<String, byte[]> attrMap = firstMutation.getAttributesMap();
+ for (MutationState.MutationMetadataType metadataType :
+ MutationState.MutationMetadataType.values()) {
+ String metadataTypeKey = metadataType.toString();
+ if (attrMap.containsKey(metadataTypeKey)) {
+ CompatIndexRegionObserver.appendToWALKey(key, metadataTypeKey,
Review comment:
Moreover, 1.3/1.4 compact classes don't have it as `static`
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-743673616
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 30s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 4 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 31s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 10m 58s | 4.x passed |
| +1 :green_heart: | compile | 1m 21s | 4.x passed |
| +1 :green_heart: | checkstyle | 9m 47s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 24s | 4.x passed |
| +0 :ok: | spotbugs | 0m 27s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 24s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 4m 9s | root in 4.x has 1005 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 44s | phoenix-core in 4.x has 951 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 25s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 6m 13s | the patch passed |
| +1 :green_heart: | compile | 1m 30s | the patch passed |
| +1 :green_heart: | cc | 1m 30s | the patch passed |
| +1 :green_heart: | javac | 1m 30s | the patch passed |
| -1 :x: | checkstyle | 9m 15s | root: The patch generated 474 new + 23163 unchanged - 157 fixed = 23637 total (was 23320) |
| +1 :green_heart: | prototool | 0m 1s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 1s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 35s | the patch passed |
| -1 :x: | spotbugs | 3m 19s | phoenix-core generated 2 new + 951 unchanged - 0 fixed = 953 total (was 951) |
| -1 :x: | spotbugs | 4m 30s | root generated 2 new + 1005 unchanged - 0 fixed = 1007 total (was 1005) |
||| _ Other Tests _ |
| -1 :x: | unit | 128m 30s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 30s | The patch does not generate ASF License warnings. |
| | | 198m 43s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| Failed junit tests | phoenix.end2end.index.ViewIndexIT |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/12/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux fbce87f802cf 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 | 4.x / d43c362 |
| 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-913/12/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/12/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/12/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/12/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/12/testReport/ |
| Max. process+thread count | 6087 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/12/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r533790609
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java
##########
@@ -98,4 +99,13 @@ public void testQueryWithMultipleColumnFamiliesAndMultipleConditionsForImmutable
}
}
}
+
+ @Test
+ public void testImmutableTableCreation() throws Exception {
Review comment:
Correct, @ChinmaySKulkarni , doesn't look like we need this. Removed it.
----------------------------------------------------------------
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 #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
stoty commented on pull request #913:
URL: https://github.com/apache/phoenix/pull/913#issuecomment-744693604
:broken_heart: **-1 overall**
| Vote | Subsystem | Runtime | Comment |
|:----:|----------:|--------:|:--------|
| +0 :ok: | reexec | 0m 41s | Docker mode activated. |
||| _ Prechecks _ |
| +1 :green_heart: | dupname | 0m 1s | 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 :green_heart: | test4tests | 0m 0s | The patch appears to include 3 new or modified test files. |
||| _ 4.x Compile Tests _ |
| +0 :ok: | mvndep | 0m 38s | Maven dependency ordering for branch |
| +1 :green_heart: | mvninstall | 11m 7s | 4.x passed |
| +1 :green_heart: | compile | 1m 28s | 4.x passed |
| +1 :green_heart: | checkstyle | 7m 31s | 4.x passed |
| +1 :green_heart: | javadoc | 2m 25s | 4.x passed |
| +0 :ok: | spotbugs | 0m 28s | phoenix-hbase-compat-1.5.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 23s | phoenix-hbase-compat-1.4.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 0m 24s | phoenix-hbase-compat-1.3.0 in 4.x has 3 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 4m 18s | root in 4.x has 1005 extant spotbugs warnings. |
| +0 :ok: | spotbugs | 2m 55s | phoenix-core in 4.x has 951 extant spotbugs warnings. |
||| _ Patch Compile Tests _ |
| +0 :ok: | mvndep | 0m 25s | Maven dependency ordering for patch |
| +1 :green_heart: | mvninstall | 6m 35s | the patch passed |
| +1 :green_heart: | compile | 1m 37s | the patch passed |
| +1 :green_heart: | cc | 1m 37s | the patch passed |
| +1 :green_heart: | javac | 1m 37s | the patch passed |
| -1 :x: | checkstyle | 7m 36s | root: The patch generated 459 new + 23220 unchanged - 157 fixed = 23679 total (was 23377) |
| +1 :green_heart: | prototool | 0m 2s | There were no new prototool issues. |
| +1 :green_heart: | whitespace | 0m 0s | The patch has no whitespace issues. |
| +1 :green_heart: | xml | 0m 2s | The patch has no ill-formed XML file. |
| +1 :green_heart: | javadoc | 2m 31s | the patch passed |
| -1 :x: | spotbugs | 3m 29s | phoenix-core generated 2 new + 951 unchanged - 0 fixed = 953 total (was 951) |
| -1 :x: | spotbugs | 4m 36s | root generated 2 new + 1005 unchanged - 0 fixed = 1007 total (was 1005) |
||| _ Other Tests _ |
| -1 :x: | unit | 127m 59s | root in the patch failed. |
| +1 :green_heart: | asflicense | 2m 33s | The patch does not generate ASF License warnings. |
| | | 195m 44s | |
| Reason | Tests |
|-------:|:------|
| FindBugs | module:phoenix-core |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| FindBugs | module:root |
| | Switch statement found in org.apache.phoenix.hbase.index.scanner.FilteredKeyValueScanner.seekToNextUnfilteredKeyValue() where default case is missing At FilteredKeyValueScanner.java:where default case is missing At FilteredKeyValueScanner.java:[lines 84-101] |
| | org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES is a mutable array At MetaDataEndpointImpl.java: At MetaDataEndpointImpl.java:[line 336] |
| Failed junit tests | phoenix.end2end.ViewMetadataIT |
| Subsystem | Report/Notes |
|----------:|:-------------|
| Docker | ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/13/artifact/yetus-general-check/output/Dockerfile |
| GITHUB PR | https://github.com/apache/phoenix/pull/913 |
| Optional Tests | dupname asflicense javac javadoc unit spotbugs hbaseanti checkstyle compile cc prototool xml |
| uname | Linux ea827aee166e 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | maven |
| Personality | dev/phoenix-personality.sh |
| git revision | 4.x / 4b272b1 |
| 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-913/13/artifact/yetus-general-check/output/diff-checkstyle-root.txt |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/13/artifact/yetus-general-check/output/new-spotbugs-phoenix-core.html |
| spotbugs | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/13/artifact/yetus-general-check/output/new-spotbugs-root.html |
| unit | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/13/artifact/yetus-general-check/output/patch-unit-root.txt |
| Test Results | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/13/testReport/ |
| Max. process+thread count | 6255 (vs. ulimit of 30000) |
| modules | C: phoenix-hbase-compat-1.5.0 phoenix-hbase-compat-1.4.0 phoenix-hbase-compat-1.3.0 phoenix-core . U: . |
| Console output | https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-913/13/console |
| versions | git=2.7.4 maven=3.3.9 spotbugs=4.1.4 prototool=1.10.0-dev |
| 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] gjacoby126 commented on a change in pull request #913: PHOENIX-5435 - Annotate HBase WALs with Phoenix Metadata
Posted by GitBox <gi...@apache.org>.
gjacoby126 commented on a change in pull request #913:
URL: https://github.com/apache/phoenix/pull/913#discussion_r541347335
##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionScanner.java
##########
@@ -64,6 +64,7 @@
import org.apache.phoenix.cache.GlobalCache;
import org.apache.phoenix.cache.TenantCache;
import org.apache.phoenix.exception.DataExceedsCapacityException;
+import org.apache.phoenix.execute.MutationState;
Review comment:
removed
----------------------------------------------------------------
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