[
https://issues.apache.org/jira/browse/HBASE-5922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13267200#comment-13267200
]
Anoop Sam John commented on HBASE-5922:
---------------------------------------
After reading the code for HalfStoreFileReader and the javadoc for the
HFileScanner.seekBefore(), got more confusion with the code...
{code}
/**
* Consider the key stream of all the keys in the file,
* <code>k[0] .. k[n]</code>, where there are n keys in the file.
* @param key Key to find
* @return false if key <= k[0] or true with scanner in position 'i' such
* that: k[i] < key. Furthermore: there may be a k[i+1], such that
* k[i] < key <= k[i+1] but there may also NOT be a k[i+1], and next() will
* return false (EOF).
* @throws IOException
*/
public boolean seekBefore(byte [] key) throws IOException;
{code}
Here is the code for seekBefore in HalfStoreFileReader
For top half file
{code}
if (top) {
if (getComparator().compare(key, offset, length, splitkey, 0,
splitkey.length) < 0) {
return false;
}
}
{code}
The top file is from [splitkey,endkey). When the passed key is less than or
equal to the splitkey, we wont be able to find a point i in the file such that
k[i]<key.. This should be a case of return false. So here we should have if
condition with <= 0 ?
Code for bottom file
{code}
else{
if (getComparator().compare(key, offset, length, splitkey, 0,
splitkey.length) >= 0) {
return seekBefore(splitkey, 0, splitkey.length);
}
}
{code}
The bottom file is from [startkey,splitkey). When the passed key is >= the
split key we can point to the last key in the file. I think for this only
seekBefore splitKey was done. But as it checks =0 also this will result in
infinite calls to seekBefore :(
So may be we can change the condition from >=0 to >0 only... Then the actual
seekBefore will be done by the delegate.seekBefore() call... But return false
for getComparator().compare(key, offset, length, splitkey, 0, splitkey.length)
>= 0 will be wrong I feel.....
@Stack, @Nate What do u say?
Also this bug is applicable for other versions too...
> HalfStoreFileReader seekBefore causes StackOverflowError
> --------------------------------------------------------
>
> Key: HBASE-5922
> URL: https://issues.apache.org/jira/browse/HBASE-5922
> Project: HBase
> Issue Type: Bug
> Components: client, io
> Affects Versions: 0.90.0
> Environment: HBase 0.90.4
> Reporter: Nate Putnam
> Assignee: Nate Putnam
> Fix For: 0.90.0
>
> Attachments: HBASE-5922.patch, HBASE-5922.patch
>
>
> Calling HRegionServer.getClosestRowBefore() can cause a stack overflow if the
> underlying store file is a reference and the row key is in the bottom.
> java.io.IOException: java.io.IOException: java.lang.StackOverflowError
> at
> org.apache.hadoop.hbase.regionserver.HRegionServer.convertThrowableToIOE(HRegionServer.java:990)
> at
> org.apache.hadoop.hbase.regionserver.HRegionServer.convertThrowableToIOE(HRegionServer.java:978)
> at
> org.apache.hadoop.hbase.regionserver.HRegionServer.getClosestRowBefore(HRegionServer.java:1651)
> at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.apache.hadoop.hbase.ipc.HBaseRPC$Server.call(HBaseRPC.java:570)
> at
> org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1039)
> Caused by: java.lang.StackOverflowError
> at
> org.apache.hadoop.hbase.io.HalfStoreFileReader$1.seekBefore(HalfStoreFileReader.java:147)
> at
> org.apache.hadoop.hbase.io.HalfStoreFileReader$1.seekBefore(HalfStoreFileReader.java:149)
> at
> org.apache.hadoop.hbase.io.HalfStoreFileReader$1.seekBefore(HalfStoreFileReader.java:149)
> at
> org.apache.hadoop.hbase.io.HalfStoreFileReader$1.seekBefore(HalfStoreFileReader.java:149)
> at
> org.apache.hadoop.hbase.io.HalfStoreFileReader$1.seekBefore(HalfStoreFileReader.java:149)
--
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