mnpoonia commented on code in PR #8622:
URL: https://github.com/apache/hbase/pull/8622#discussion_r4008024613


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestOpenRegionProcedureRestoreFailedOpen.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.hadoop.hbase.HConstants;
+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.RegionState;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionRequest.RegionOpenInfo;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionResponse.RegionOpeningState;
+import 
org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
+
+/**
+ * HBASE-30357: OpenRegionProcedure#restoreSucceedState() must not force the 
region state to OPEN on
+ * master-failover restore when the persisted transition code is actually 
FAILED_OPEN.
+ */
+@Tag(MasterTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestOpenRegionProcedureRestoreFailedOpen extends 
TestAssignmentManagerBase {
+
+  /**
+   * On the first open attempt, reports FAILED_OPEN and then immediately 
simulates a master restart

Review Comment:
   Good question. We don’t actually restart the master in this test.
   
   The test simulates the relevant part of a master restart by directly 
invoking TransitRegionStateProcedure#stateLoaded(), which is the hook reached 
when the procedure state is loaded during master recovery.
   
   The important sequence we want to reproduce is:
   
   1. RS reports FAILED_OPEN.
   2. The procedure state containing REPORT_SUCCEED + FAILED_OPEN is persisted.
   3. Master crashes before the child procedure gets a chance to continue and 
update the region state/meta.
   4. On recovery, stateLoaded() restores the procedure and calls 
restoreSucceedState().
   
   The test holds the RegionStateNode lock after reporting FAILED_OPEN and 
invokes stateLoaded() directly, so the child procedure cannot continue 
normally. This puts us at the same point in the procedure lifecycle as the 
restore path after a master restart.
   
   I can make the test/comment more explicit about this, e.g. rename the 
comment from “simulates a master restart” to “simulates procedure recovery 
after master restart”, to avoid suggesting that the test actually restarts the 
master.



-- 
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]

Reply via email to