[ 
https://issues.apache.org/jira/browse/HBASE-543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12658626#action_12658626
 ] 

Jim Kellerman commented on HBASE-543:
-------------------------------------

@Stack:

> There is a bunch of redoing of state processing but no explanation
> as to why? For example: 
>
{code}
+   * Remove a region from the region state map.
+   * 
+   * @param info
+   */
+  public void removeRegion(HRegionInfo info) {
{code}
>
> Under what circumstance would I remove a region from state map?
>
> The region state map itself has no explanation:
>
{code}
+  // Needs to be SortedMap so we can specify a comparator
+  private final SortedMap<byte[], RegionState> regionState =
+    Collections.synchronizedSortedMap(
+        new TreeMap<byte[], RegionState>(Bytes.BYTES_COMPARATOR));
{code}
>
> The maps it would replace tried to explain what they were about.
> Nor does the new RegionState map.

Good points. The name of the map should really be regionsInTransition,
so removeRegion is called when a region completes the transitions from

unassigned -> assigned -> pending -> open

closing -> closed -> offline

closing -> closed -> unassigned -> assigned -> pending -> open

I will update the documentation and change the name of the map.

> With above said, looks like this could be an improvement in that
> state is all in one place. 

Yes, it is no longer possible for a region to be in multiple states at
once as state transitions always clear all the other states.

> Should RegionState be looking for illegal states? It doesn't seem to
> do any checking. This would be a good place to check we're doing
> transitions properly.

Good point. It should at least check for valid state transitions to
make sure that they happen in the proper order. Will update to include
this.

> Should resetting of connection root region be done inside
> unsetRootRegion in below so the two actions are tied together: 
>
{code}
+      master.connection.setRootRegionLocation(null);
+      master.regionManager.unsetRootRegion();
{code}

Yes. Good idea. The connection is visible inside this method.

> Does unsetRootRegion set root region to null in regionManger?

Yes.

> Maybe connection and regionManager both need an unsetRootRegion
> method (or both a setRootRegionLocation that takes null) so same
> action in two places uses similarily named methods (This stuff
> preexisted your patch). 

Yes. I think connection should have an unsetRootRegion instead of
setRootRegion(null). setRootRegion should only take a valid
HServerAddress. 

> In RegionState, data members are named isUnassigned, isClosing,
> etc. Usual javabean convention is that data members are named
> unassigned, closing, etc. and that isClosing is one of the names
> getters have.

Ok, no problem.

> Why dumpState and not toString?

No good reason. I was using it for debugging, and was going to remove
it, but having a toString is a good idea.

===

Making the above edits now. Do you want to re-review the patch when I'm done, 
or should I commit?

> A region's state is kept in several places in the master opening the 
> possibility for race conditions
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-543
>                 URL: https://issues.apache.org/jira/browse/HBASE-543
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: master
>    Affects Versions: 0.1.0, 0.1.1, 0.2.0
>            Reporter: Jim Kellerman
>            Assignee: Jim Kellerman
>             Fix For: 0.19.0
>
>         Attachments: 543.patch, 543.patch, recent-changes.patch, 
> regionstate.txt
>
>
> A region's state exists in multiple maps in the RegionManager: 
> unassignedRegions, pendingRegions, regionsToClose, closingRegions, 
> regionsToDelete, etc.
> One of these race conditions was found in HBASE-534.
> For HBase-0.1.x, we should just patch the holes we find.
> The ultimate solution (which requires a lot of changes in HMaster) should be 
> applied to HBase trunk.
> Proposed solution:
> Create a class that encapsulates a region's state and provide synchronized 
> access to the class that validates state changes.
> There should be a single structure that holds regions in these transitional 
> states and it should be a synchronized collection of some kind.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to