Apache9 commented on a change in pull request #2497:
URL: https://github.com/apache/hbase/pull/2497#discussion_r501539893



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
##########
@@ -870,32 +870,49 @@ public TransitRegionStateProcedure 
createOneUnassignProcedure(RegionInfo ri, boo
       
.sorted(AssignmentManager::compare).toArray(TransitRegionStateProcedure[]::new);
   }
 
+  // for creating unassign TRSP when disabling a table or closing excess 
region replicas
+  private TransitRegionStateProcedure 
forceCreateUnssignProcedure(RegionStateNode regionNode) {
+    regionNode.lock();
+    try {
+      if (!regionStates.include(regionNode, false) ||
+        regionStates.isRegionOffline(regionNode.getRegionInfo())) {
+        return null;
+      }
+      // As in DisableTableProcedure or ModifyTableProcedure, we will hold the 
xlock for table, so
+      // we can make sure that this procedure has not been executed yet, as 
TRSP will hold the
+      // shared lock for table all the time. So here we will unset it and when 
it is actually
+      // executed, it will find that the attach procedure is not itself and 
quit immediately.
+      if (regionNode.getProcedure() != null) {

Review comment:
       This is a fencing mechanism to prevent double assign. We have a 
procedure field for every region node, before scheduling a new TRSP for a 
region, we should attach the TRSP to this field, if there is already one, we 
will fail immediately.
   And here, the trick is the locking for procedures, for ModifyTableProcedure 
and DisableTableProcedure, we will hold the exclusive lock on the table, while 
for a TRSP, we will hold the shared lock on the table. Both locks will be held 
through the whole life cycle of the procedure, so here, since we hae already 
held the exclusive lock on the table, we can make sure that, even if there is 
already a TRSP attached, it has not been executed yet, so it is safe to 
'abandon' and attach a new TRSP to close it. The actual 'abandon' is done in 
the execute method in TRSP, it will check whether it is still the one attached, 
if not, it will quit immediately.

##########
File path: 
hbase-protocol-shaded/src/main/protobuf/server/master/MasterProcedure.proto
##########
@@ -72,6 +72,8 @@ enum ModifyTableState {
   MODIFY_TABLE_DELETE_FS_LAYOUT = 5;
   MODIFY_TABLE_POST_OPERATION = 6;
   MODIFY_TABLE_REOPEN_ALL_REGIONS = 7;
+  MODIFY_TABLE_CLOSE_EXCESS_REPLICAS = 8;
+  MODIFY_TABLE_ASSIGN_NEW_REPLICAS = 9;

Review comment:
       Yes.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to