Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-22980

HRegionPartioner getPartition() method incorrectly partitions the regions of the table.

    XMLWordPrintableJSON

    Details

      Description

      Problem:
      Partitioner class HRegionPartitioner in a HBase MapReduce job has a method getPartition(). In getPartition(), there is a scenario where we have check for less number of reducers than region. This scenario seems incorrect because for a rowKey present in last region(let us say nth region) , getPartition() should return value (n-1). But it is not returning n-1 for the last region as it is falling in the case where number of reducers < number of regions and returning some random value.

      So if a client uses this class as a partitioner class in HBase MapReduce jobs, this method incorrectly partitions the regions because rowKeys present in the last regions does not fall to the last region.

      https://github.com/apache/hbase/blob/fbd5b5e32753104f88600b0f4c803ab5659bce64/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HRegionPartitioner.java#L92

      Consider the following scenario:

      if there are 5 regions for the table, partitions = 5 and number of reducers is also 5.
      So in this case above check for reducers < regions should not return true.
      But for the last region when i=4(last region, 5th region) , getPartition should return 4 but it returns 2 because it falls in the case of when we have less reduces than region and returns true for the above condition even though we have reducers = regions. So the condition is incorrect.
       
      Solution:
      Instead of

       if (i >= numPartitions-1) 

      It should be

       if (i >= numPartitions){  

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shardulsingh Shardul Singh
                Reporter:
                shardulsingh Shardul Singh
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: