Guanghao Zhang commented on HBASE-19965:

When split a region, the parent region was marked as State.SPLIT. And the 
daughter regions were marked as State.SPLITTING_NEW. But for merge regions, 
only the new child region was marked State.MERGED. And don't change the parent 
regions state.
  public void markRegionAsSplit(final RegionInfo parent, final ServerName 
      final RegionInfo daughterA, final RegionInfo daughterB)
  throws IOException {
    // Update hbase:meta. Parent will be marked offline and split up in 
    // The parent stays in regionStates until cleared when removed by 
    // Update its state in regionStates to it shows as offline and split when 
    // later figuring what regions are in a table and what are not: see
    // regionStates#getRegionsOfTable
    final RegionStateNode node = 
    final RegionStateNode nodeA = 
    final RegionStateNode nodeB = 

    regionStateStore.splitRegion(parent, daughterA, daughterB, serverName);
    if (shouldAssignFavoredNodes(parent)) {
      List<ServerName> onlineServers = 
          generateFavoredNodesForDaughter(onlineServers, parent, daughterA, 

   * When called here, the merge has happened. The two merged regions have been
   * unassigned and the above markRegionClosed has been called on each so they 
have been
   * disassociated from a hosting Server. The merged region will be open after 
this call. The
   * merged regions are removed from hbase:meta below> Later they are deleted 
from the filesystem
   * by the catalog janitor running against hbase:meta. It notices when the 
merged region no
   * longer holds references to the old regions.
  public void markRegionAsMerged(final RegionInfo child, final ServerName 
      final RegionInfo mother, final RegionInfo father) throws IOException {
    final RegionStateNode node = regionStates.getOrCreateRegionStateNode(child);
    regionStateStore.mergeRegions(child, mother, father, serverName);
    if (shouldAssignFavoredNodes(child)) {
        generateFavoredNodesForMergedRegion(child, mother, father);

> Fix flaky TestAsyncRegionAdminApi
> ---------------------------------
>                 Key: HBASE-19965
>                 URL: https://issues.apache.org/jira/browse/HBASE-19965
>             Project: HBase
>          Issue Type: Sub-task
>            Reporter: Guanghao Zhang
>            Priority: Major
> See 
> [https://builds.apache.org/job/HBase%20Nightly/job/branch-2/284/testReport/junit/org.apache.hadoop.hbase.client/TestAsyncRegionAdminApi/testMergeRegions_0_/]
> java.lang.AssertionError: expected:<2> but was:<3> at 
> org.apache.hadoop.hbase.client.TestAsyncRegionAdminApi.testMergeRegions(TestAsyncRegionAdminApi.java:359)
> Merge regions not work. The table still have 3 regions after the 
> MergeRegionsProcedure finished.
> The master start balance region 9e2773ba1efba79a2defa276e9a26ed4. But because 
> the MergeRegionsProcedure pid=138 start work first, so the balance need wait 
> for the lock. But after merge regions finished, the MoveRegionProcedure 
> pid=139 start work and assign 9e2773ba1efba79a2defa276e9a26ed4 to a new 
> region server. This is not right. The MoveRegionProcedure should skip to 
> assign a region which was marked as offline. Or we should clear the merged 
> regions' procedure when MergeRegionsProcedure finished.
> Logs:
> 2018-02-08 16:24:44,608 INFO [master/cd4730e3eae2:0.Chore.1] 
> master.HMaster(1454): balance 
> hri=testMergeRegions,,1518107079782.9e2773ba1efba79a2defa276e9a26ed4., 
> source=cd4730e3eae2,39077,1518106776411, 
> destination=cd4730e3eae2,40578,1518106776318
> 2018-02-08 16:24:44,608 DEBUG 
> [RpcServer.default.FPBQ.Fifo.handler=4,queue=0,port=37885] 
> procedure2.ProcedureExecutor(868): Stored pid=138, 
> state=RUNNABLE:MERGE_TABLE_REGIONS_PREPARE; MergeTableRegionsProcedure 
> table=testMergeRegions, regions=[9e2773ba1efba79a2defa276e9a26ed4, 
> 8f8fd5cd032313e1aadb83e31e1b7479], forcibly=false
> ......
> 2018-02-08 16:24:50,111 INFO [PEWorker-13] 
> procedure2.ProcedureExecutor(1249): Finished pid=138, state=SUCCESS; 
> MergeTableRegionsProcedure table=testMergeRegions, 
> regions=[9e2773ba1efba79a2defa276e9a26ed4, 8f8fd5cd032313e1aadb83e31e1b7479], 
> forcibly=false in 5.5710sec
> 2018-02-08 16:24:50,113 INFO [PEWorker-13] 
> procedure.MasterProcedureScheduler(813): pid=139, 
> state=RUNNABLE:MOVE_REGION_UNASSIGN; MoveRegionProcedure 
> hri=testMergeRegions,,1518107079782.9e2773ba1efba79a2defa276e9a26ed4., 
> source=cd4730e3eae2,39077,1518106776411, 
> destination=cd4730e3eae2,40578,1518106776318 testMergeRegions 
> testMergeRegions,,1518107079782.9e2773ba1efba79a2defa276e9a26ed4.

This message was sent by Atlassian JIRA

Reply via email to