ndimiduk commented on code in PR #6905:
URL: https://github.com/apache/hbase/pull/6905#discussion_r2042507435
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionRemoteProcedureBase.java:
##########
@@ -296,12 +296,25 @@ private void setFuture(CompletableFuture<Void> f) {
}
@Override
- protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env)
- throws ProcedureYieldException, ProcedureSuspendedException,
InterruptedException {
+ protected void beforeExec(MasterProcedureEnv env) throws
ProcedureSuspendedException {
RegionStateNode regionNode = getRegionNode(env);
if (!regionNode.isLockedBy(this)) {
regionNode.lock(this, () -> ProcedureFutureUtil.wakeUp(this, env));
}
+ }
+
+ @Override
+ protected void afterExec(MasterProcedureEnv env) {
+ if (future == null) {
Review Comment:
I guess we did so before, but it sure looks odd to only conditionally
release the lock.
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTRSPPersistUninitializedSubProc.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.hadoop.hbase.master.assignment;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.master.HMaster;
+import
org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure.TransitionType;
+import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
+import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
+import org.apache.hadoop.hbase.procedure2.Procedure;
+import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
+import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
+import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
+import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import
org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
+
+/**
+ * Testcase for HBASE-29259
+ */
+@Category({ MasterTests.class, MediumTests.class })
+public class TestTRSPPersistUninitializedSubProc {
+
+ @ClassRule
+ public static final HBaseClassTestRule CLASS_RULE =
+ HBaseClassTestRule.forClass(TestTRSPPersistUninitializedSubProc.class);
+
+ private static HBaseTestingUtil UTIL = new HBaseTestingUtil();
+
+ private static byte[] CF = Bytes.toBytes("cf");
+
+ private static TableName TN = TableName.valueOf("tn");
+
+ public static class TRSPForTest extends TransitRegionStateProcedure {
+
+ private boolean injected = false;
+
+ public TRSPForTest() {
+ }
+
+ public TRSPForTest(MasterProcedureEnv env, RegionInfo hri, ServerName
assignCandidate,
+ boolean forceNewPlan, TransitionType type) {
+ super(env, hri, assignCandidate, forceNewPlan, type);
+ }
+
+ @Override
+ protected Procedure[] execute(MasterProcedureEnv env)
+ throws ProcedureSuspendedException, ProcedureYieldException,
InterruptedException {
+ Procedure[] subProcs = super.execute(env);
+ if (!injected && subProcs != null && subProcs[0] instanceof
CloseRegionProcedure) {
+ injected = true;
+ ServerName sn = ((CloseRegionProcedure) subProcs[0]).targetServer;
+ env.getMasterServices().getServerManager().expireServer(sn);
+ try {
+ UTIL.waitFor(15000, () ->
env.getMasterServices().getProcedures().stream().anyMatch(
Review Comment:
Might as well make this retry for some long duration, like 5 mins?
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestTRSPPersistUninitializedSubProc.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.hadoop.hbase.master.assignment;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.master.HMaster;
+import
org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure.TransitionType;
+import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
+import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
+import org.apache.hadoop.hbase.procedure2.Procedure;
+import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
+import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
+import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
+import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import
org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
+
+/**
+ * Testcase for HBASE-29259
+ */
+@Category({ MasterTests.class, MediumTests.class })
+public class TestTRSPPersistUninitializedSubProc {
+
+ @ClassRule
+ public static final HBaseClassTestRule CLASS_RULE =
+ HBaseClassTestRule.forClass(TestTRSPPersistUninitializedSubProc.class);
+
+ private static HBaseTestingUtil UTIL = new HBaseTestingUtil();
+
+ private static byte[] CF = Bytes.toBytes("cf");
+
+ private static TableName TN = TableName.valueOf("tn");
+
+ public static class TRSPForTest extends TransitRegionStateProcedure {
+
+ private boolean injected = false;
+
+ public TRSPForTest() {
+ }
+
+ public TRSPForTest(MasterProcedureEnv env, RegionInfo hri, ServerName
assignCandidate,
+ boolean forceNewPlan, TransitionType type) {
+ super(env, hri, assignCandidate, forceNewPlan, type);
+ }
+
+ @Override
+ protected Procedure[] execute(MasterProcedureEnv env)
+ throws ProcedureSuspendedException, ProcedureYieldException,
InterruptedException {
+ Procedure[] subProcs = super.execute(env);
+ if (!injected && subProcs != null && subProcs[0] instanceof
CloseRegionProcedure) {
+ injected = true;
+ ServerName sn = ((CloseRegionProcedure) subProcs[0]).targetServer;
+ env.getMasterServices().getServerManager().expireServer(sn);
+ try {
+ UTIL.waitFor(15000, () ->
env.getMasterServices().getProcedures().stream().anyMatch(
+ p -> p instanceof ServerCrashProcedure && p.getState() !=
ProcedureState.INITIALIZING));
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ // sleep 10 seconds to let the SCP interrupt the TRSP, where we will
call TRSP.serverCrashed
+ Thread.sleep(10000);
Review Comment:
Will this be long enough for consistent behavior on Jenkins? What if this
thread blocked indefinitely, would the rest of the system process as expected?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]