You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "ritegarg (via GitHub)" <gi...@apache.org> on 2025/06/20 01:03:01 UTC
[PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
ritegarg opened a new pull request, #2198:
URL: https://github.com/apache/phoenix/pull/2198
(no 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.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "jpisaac (via GitHub)" <gi...@apache.org>.
jpisaac commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2164814308
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
nit: some (lower case) instead on Some
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially set up non-blocking CRR
+ ClusterRoleRecord crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutation should work
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'David', 40)");
+ conn.commit();
+
+ // Transition to ACTIVE_TO_STANDBY (blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 2L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Now mutations should be blocked
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Eve', 33)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException after transition to ACTIVE_TO_STANDBY");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception after transition",
+ containsMutationBlockedException(e));
+ }
+
+ // Transition back to STANDBY (non-blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ 3L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work again
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
Review Comment:
@ritegarg Do we have similar tests in Failover and ParallelConnectionIT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2157957936
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
Review Comment:
You are assuming this is using Failover Connection and in FailoverConnectionIT, this is simple connection using URL we have.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162251672
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
IMO, this is more specific. There can be multiple CRRs. Current logic is that even if one of the CRR is in ATS state we block the mutation. Currently this means that cluster itself is in CRR state but in future if we can identify traffic based on HAGroup(or CRR) we can selectively block mutations for that HAGroup as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "jpisaac (via GitHub)" <gi...@apache.org>.
jpisaac merged PR #2198:
URL: https://github.com/apache/phoenix/pull/2198
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162529782
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
No, that is not in current implementation. Currently it only watches the current cluster and not peer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162212101
##########
phoenix-core/src/it/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionIT.java:
##########
@@ -250,6 +257,48 @@ public void testCluster1OfflineRole() throws Exception {
}
}
+ /**
+ * Test Phoenix connection creation and basic operations with HBase both cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void bothClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE_TO_STANDBY);
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
Review Comment:
We need to have assert.fail statement either in try or catch block? I assume since both the clusters are in ATS state, these operations will fail so we need to have assert.fail statement in try block?
##########
phoenix-core/src/it/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionIT.java:
##########
@@ -250,6 +257,48 @@ public void testCluster1OfflineRole() throws Exception {
}
}
+ /**
+ * Test Phoenix connection creation and basic operations with HBase both cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void bothClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE_TO_STANDBY);
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
+ assertTrue(containsMutationBlockedException(e));
+ }
+ }
+
+ /**
+ * Test Phoenix connection creation and basic operations with HBase one cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void oneClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE);
+ int countExceptions = 0;
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
Review Comment:
similar comment as above.
##########
phoenix-core/src/it/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionIT.java:
##########
@@ -250,6 +257,48 @@ public void testCluster1OfflineRole() throws Exception {
}
}
+ /**
+ * Test Phoenix connection creation and basic operations with HBase both cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void bothClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE_TO_STANDBY);
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
Review Comment:
Do we have any checks whether both the clusters can be in ATS state? I know we have check where both the clusters cannot be in ACTIVE state.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162527066
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
> This will be handled in Consistent Failover.
Didn't understand this comment? In the current implementation can a regionserver have a watcher pointing to different clusters? @ritegarg
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162527066
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
> This will be handled in Consistent Failover.
Didn't understand this comment? In the current implementation can a regionserver have a watcher pointing to different clusters CRR? @ritegarg
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162363187
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
> There can be multiple CRRs
For a given cluster on the server side, it will always watch its own local ZK's CRR. Even if this cluster is marked ATS on some other cluster's CRR, how will this cluster get notified when we change the role in other cluster's CRR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162503446
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
That is not in scope for changes in PHOENIX-7493. This will be handled in Consistent Failover.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2157953569
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially set up non-blocking CRR
+ ClusterRoleRecord crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutation should work
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'David', 40)");
+ conn.commit();
+
+ // Transition to ACTIVE_TO_STANDBY (blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 2L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Now mutations should be blocked
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Eve', 33)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException after transition to ACTIVE_TO_STANDBY");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception after transition",
+ containsMutationBlockedException(e));
+ }
+
+ // Transition back to STANDBY (non-blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ 3L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work again
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
Review Comment:
Currently we only block the mutations when current cluster role is ATS. In any other case we don't block. ParallelConnection can still write to a cluster in Standby State
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2159390339
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially set up non-blocking CRR
+ ClusterRoleRecord crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutation should work
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'David', 40)");
+ conn.commit();
+
+ // Transition to ACTIVE_TO_STANDBY (blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 2L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Now mutations should be blocked
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Eve', 33)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException after transition to ACTIVE_TO_STANDBY");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception after transition",
+ containsMutationBlockedException(e));
+ }
+
+ // Transition back to STANDBY (non-blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ 3L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work again
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
Review Comment:
Added tests for [ParallelPhoenixConnectionIT.java](https://github.com/apache/phoenix/pull/2198/files#diff-70800ab3f4d05a909c26f4a905f6830b5161a7b3a7aa69991ac4412d3cdd0ec5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162134807
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
should the comment be like:
`Blocking Mutation as this cluster is in ACTIVE_TO_STANDBY state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162363187
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
> There can be multiple CRRs
For a given cluster on the server side, it will always watch it owns local ZK's CRR. Even if this cluster is marked ATS on some other cluster's CRR, how will this cluster get notified when we change the role in other cluster's CRR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2167475572
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -540,8 +541,9 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
final Configuration conf = c.getEnvironment().getConfiguration();
final HAGroupStoreManager haGroupStoreManager = HAGroupStoreManager.getInstance(conf);
if (haGroupStoreManager.isMutationBlocked()) {
- throw new IOException("Blocking Mutation as Some CRRs are in ACTIVE_TO_STANDBY "
- + "state and CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED is true");
+ throw new MutationBlockedIOException("Blocking Mutation as Some CRRs "
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2157891249
##########
phoenix-core-client/src/main/java/org/apache/phoenix/exception/MutationBlockedIOException.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.exception;
+
+import java.io.IOException;
+
+
Review Comment:
Add javadoc
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially set up non-blocking CRR
+ ClusterRoleRecord crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutation should work
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'David', 40)");
+ conn.commit();
+
+ // Transition to ACTIVE_TO_STANDBY (blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 2L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Now mutations should be blocked
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Eve', 33)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException after transition to ACTIVE_TO_STANDBY");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception after transition",
+ containsMutationBlockedException(e));
+ }
+
+ // Transition back to STANDBY (non-blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ 3L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work again
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
Review Comment:
How come this works? Are we sure that conn object talks to cluster with URL "standby-zk-url" which is currently active? If yes, where is that cluster? We are re-using the connection object that is pointing to first cluster.
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially set up non-blocking CRR
+ ClusterRoleRecord crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutation should work
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'David', 40)");
+ conn.commit();
+
+ // Transition to ACTIVE_TO_STANDBY (blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
Review Comment:
can we add a test case where we change haAdmin.getZkUrl() back to Active from ATS state and make sure write to this cluster succeeds? This is required in case we have to rollback the state change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "shahrs87 (via GitHub)" <gi...@apache.org>.
shahrs87 commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2157903380
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
Review Comment:
Why are we creating connection with a specific URL? Shouldn't we use some generic getConnection method that will lookup in CRR which cluster is active and create connection to that cluster?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162509524
##########
phoenix-core/src/it/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionIT.java:
##########
@@ -250,6 +257,48 @@ public void testCluster1OfflineRole() throws Exception {
}
}
+ /**
+ * Test Phoenix connection creation and basic operations with HBase both cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void bothClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE_TO_STANDBY);
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
Review Comment:
This is part of client code which is not under test. Removed these tests for now as per our discussion
##########
phoenix-core/src/it/java/org/apache/phoenix/jdbc/ParallelPhoenixConnectionIT.java:
##########
@@ -250,6 +257,48 @@ public void testCluster1OfflineRole() throws Exception {
}
}
+ /**
+ * Test Phoenix connection creation and basic operations with HBase both cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void bothClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE_TO_STANDBY);
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
+ assertTrue(containsMutationBlockedException(e));
+ }
+ }
+
+ /**
+ * Test Phoenix connection creation and basic operations with HBase one cluster is ACTIVE_TO_STANDBY role.
+ */
+ @Test
+ public void oneClusterATSRole() throws Exception {
+ CLUSTERS.transitClusterRole(haGroup, ClusterRole.ACTIVE_TO_STANDBY, ClusterRole.ACTIVE);
+ int countExceptions = 0;
+ try (Connection conn = getParallelConnection()) {
+ doTestBasicOperationsWithConnection(conn, tableName, haGroupName);
+ } catch (SQLException e) {
Review Comment:
Same as above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2162504423
##########
phoenix-core-client/src/main/java/org/apache/phoenix/exception/MutationBlockedIOException.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.exception;
+
+import java.io.IOException;
+
+
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.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] PHOENIX-7598 Add ITs for client write behavior when they encounter ATS state [phoenix]
Posted by "ritegarg (via GitHub)" <gi...@apache.org>.
ritegarg commented on code in PR #2198:
URL: https://github.com/apache/phoenix/pull/2198#discussion_r2157954133
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexRegionObserverMutationBlockingIT.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.index;
+
+import static org.apache.phoenix.jdbc.PhoenixHAAdmin.toPath;
+import static org.apache.phoenix.query.QueryServices.CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.exception.MutationBlockedIOException;
+import org.apache.phoenix.execute.CommitException;
+import org.apache.phoenix.jdbc.ClusterRoleRecord;
+import org.apache.phoenix.jdbc.HAGroupStoreManager;
+import org.apache.phoenix.jdbc.HighAvailabilityPolicy;
+import org.apache.phoenix.jdbc.PhoenixHAAdmin;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration test for mutation blocking functionality in IndexRegionObserver.preBatchMutate()
+ * Tests that MutationBlockedIOException is properly thrown when cluster role-based mutation
+ * blocking is enabled and CRRs are in ACTIVE_TO_STANDBY state.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class IndexRegionObserverMutationBlockingIT extends BaseTest {
+
+ private static final Long ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS = 1000L;
+ private PhoenixHAAdmin haAdmin;
+ private HAGroupStoreManager haGroupStoreManager;
+
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+ // Enable cluster role-based mutation blocking
+ props.put(CLUSTER_ROLE_BASED_MUTATION_BLOCK_ENABLED, "true");
+ setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ haAdmin = new PhoenixHAAdmin(config);
+ haGroupStoreManager = HAGroupStoreManager.getInstance(config);
+
+ // Clean up all existing CRRs before each test
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Clean up CRRs after each test
+ if (haAdmin != null) {
+ List<ClusterRoleRecord> crrs = haAdmin.listAllClusterRoleRecordsOnZookeeper();
+ for (ClusterRoleRecord crr : crrs) {
+ haAdmin.getCurator().delete().forPath(toPath(crr.getHaGroupName()));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnDataTableWithIndex() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially, mutations should work - verify baseline
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'John', 25)");
+ conn.commit();
+
+ // Set up CRR that will block mutations (ACTIVE_TO_STANDBY state)
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("failover_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ // Wait for the event to propagate
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Verify that mutations are now blocked
+ assertTrue("Mutations should be blocked", haGroupStoreManager.isMutationBlocked());
+
+ // Test that UPSERT throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Jane', 30)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown");
+ } catch (CommitException e) {
+ // Verify the exception chain contains MutationBlockedIOException
+ assertTrue("Expected MutationBlockedIOException in exception chain",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockedOnLocalIndexTable() throws Exception {
+ String dataTableName = generateUniqueName();
+ String localIndexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and local index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE LOCAL INDEX " + localIndexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR that will block mutations
+ ClusterRoleRecord blockingCrr = new ClusterRoleRecord("local_index_test",
+ HighAvailabilityPolicy.PARALLEL,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE_TO_STANDBY,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(blockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Test that UPSERT with local index also throws MutationBlockedIOException
+ try {
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Alice', 28)");
+ conn.commit();
+ fail("Expected MutationBlockedIOException to be thrown for local index");
+ } catch (CommitException e) {
+ assertTrue("Expected mutation blocked exception",
+ containsMutationBlockedException(e));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationAllowedWhenNotBlocked() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Set up CRR in ACTIVE state (should not block)
+ ClusterRoleRecord nonBlockingCrr = new ClusterRoleRecord("active_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(nonBlockingCrr);
+
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutations should work fine
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'Bob', 35)");
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('2', 'Carol', 27)");
+ conn.commit();
+
+ // Verify data was inserted successfully
+ try (java.sql.ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT COUNT(*) FROM " + dataTableName)) {
+ assertTrue(rs.next());
+ assertEquals(2, rs.getInt(1));
+ }
+ }
+ }
+
+ @Test
+ public void testMutationBlockingTransition() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexName = generateUniqueName();
+
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ // Create data table and index
+ conn.createStatement().execute("CREATE TABLE " + dataTableName +
+ " (id VARCHAR PRIMARY KEY, name VARCHAR, age INTEGER)");
+ conn.createStatement().execute("CREATE INDEX " + indexName +
+ " ON " + dataTableName + "(name)");
+
+ // Initially set up non-blocking CRR
+ ClusterRoleRecord crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
+ ClusterRoleRecord.ClusterRole.ACTIVE,
+ "standby-zk-url",
+ ClusterRoleRecord.ClusterRole.STANDBY,
+ 1L);
+ haAdmin.createOrUpdateDataOnZookeeper(crr);
+ Thread.sleep(ZK_CURATOR_EVENT_PROPAGATION_TIMEOUT_MS);
+
+ // Mutation should work
+ conn.createStatement().execute("UPSERT INTO " + dataTableName +
+ " VALUES ('1', 'David', 40)");
+ conn.commit();
+
+ // Transition to ACTIVE_TO_STANDBY (blocking state)
+ crr = new ClusterRoleRecord("transition_test",
+ HighAvailabilityPolicy.FAILOVER,
+ haAdmin.getZkUrl(),
Review Comment:
I don't think it should matter with current logic of blocking mutations. Only ATS state is blocked, any other state is not blocked.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@phoenix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org