You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Sandy Pratt (Resolved) (JIRA)" <ji...@apache.org> on 2012/02/03 21:21:54 UTC

[jira] [Resolved] (HBASE-5331) Off by one bug in util.HMerge

     [ https://issues.apache.org/jira/browse/HBASE-5331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sandy Pratt resolved HBASE-5331.
--------------------------------

    Resolution: Not A Problem

Already fixed on trunk
                
> Off by one bug in util.HMerge
> -----------------------------
>
>                 Key: HBASE-5331
>                 URL: https://issues.apache.org/jira/browse/HBASE-5331
>             Project: HBase
>          Issue Type: Bug
>          Components: util
>    Affects Versions: 0.90.1
>         Environment: NA
>            Reporter: Sandy Pratt
>             Fix For: 0.94.0
>
>
> It looks like there's an off by one bug in the OfflineMerger constructor in util.HMerge:
>       InternalScanner rootScanner =
>         root.getScanner(scan);
>       try {
>         List<KeyValue> results = new ArrayList<KeyValue>();
>         while(rootScanner.next(results)) {
>           for(KeyValue kv: results) {
>             HRegionInfo info = Writables.getHRegionInfoOrNull(kv.getValue());
>             if (info != null) {
>               metaRegions.add(info);
>             }
>           }
>         }
>       } finally {
> 	...
>       }
> That call to InternalScanner.next() in the while condition returns true if there's another result *after* the one it just loaded into the out param.  That is, after it reads the last row into the 'results' collection, it returns false and the loop exits with that last row unread.  It probably wants to be structured more like this:
> final InternalScanner metaScanner = meta.getScanner(scan); List<KeyValue> results = Lists.newArrayList();
> while (true) {
> 	boolean hasMore = metaScanner.next(results);
> 	for (KeyValue kv : results) {
> 		HRegionInfo hri = Writables.getHRegionInfoOrNull(kv.getValue());
> 		if (hri != null) {
> 			regionInfo.add(hri);
> 		}
> 	}
> 					
> 	if (!hasMore) {
> 		break;
> 	}
> }
> The loop in util.HMerge is scanning ROOT for META regions.  So this bug will only be hit when there is more than one region of META.  Personally, I don't have any installations with more than one META region, and I'm not sure if anyone does, so this might be a moot point.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira