Home Forums HBase HBase InternalScanner scan seems to be stuck in endless loop

This topic contains 5 replies, has 5 voices, and was last updated by  tedr 1 year, 1 month ago.

  • Creator
    Topic
  • #29732

    Julius Lerm
    Member

    I am trying to implement an endpoint coprocessor.
    This current attempt simply tries to do a full scan on a region and stop when it reaches the last record in the region.
    The problem is the internal scanner seems to be in endless loop, as if the scanner.next() always returns true.
    I placed a test for “nScannedRecs”, so when it reaches a certain limit, the loop stops.
    No matter how large I make that limit, the scanner keeps going.
    I know for sure I don’t have more than 200million records in the table.
    But even if I make the limit something like 999999999999, the scanner reaches that limit.
    Any ideas?
    Thanks, Julius

    package com.wacme.extensions.coprocessor;

    import org.apache.hadoop.hbase.*;
    import org.apache.hadoop.hbase.coprocessor.*;
    import org.apache.hadoop.hbase.client.*;
    import org.apache.hadoop.hbase.regionserver.*;
    import java.util.*;

    public class ColocatedJoinEndpoint extends BaseEndpointCoprocessor implements
    ColocatedJoinProtocol {

    @Override
    public String doWork(String param1) {

    RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment)getEnvironment();

    final byte[] startKey = ” “.getBytes();
    final byte[] endKey = “zzzzzzzzzzzzzzzzzzzzz”.getBytes();

    long nScannedRecs=0;
    String keysListStr=””;

    try {
    Scan scan = new Scan(startKey);
    scan.addColumn(“cf”.getBytes(), “d”.getBytes() );
    scan.setMaxVersions(1);
    InternalScanner scanner = env.getRegion().getScanner(scan);
    long sum = 0;

    List results = new ArrayList();
    boolean hasMore = false;

    do {
    results.clear();
    hasMore = scanner.next(results);
    sum += results.size();
    nScannedRecs += sum;
    if (results.size()==0) break;

    if (nScannedRecs > 999999999999l) break;
    } while (hasMore);
    scanner.close();
    }
    catch (Exception e) {
    System.err.println(“Exception: ” + e.getMessage());
    }

    String regName = new String(env.getRegion().getRegionName());
    return “(v4)Server doWork result: received: ” + param1 + ” returning: ” + regName + ” #recs scanned: ” + nScannedRecs + ” key list: ” + keysListStr;
    }

    }

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

  • Author
    Replies
  • #29882

    tedr
    Moderator

    Hi Julius,

    thanks for letting us know.

    Ted.

    Collapse
    #29830

    Julius Lerm
    Participant

    Sasha,

    I managed to figure out what the problem was: the requests were taking too long and therefore would time out.
    As a consequence, the requests would keep being re-submitted, hence the impression that the coprocessor was in perpetual loop.

    Once I increased the hbase rpc timeout to a much larger value, the behavior was corrected and the results as expected.

    Thanks for taking a look into this.

    Cheers.

    Julius

    Collapse
    #29829

    Julius Lerm
    Participant

    Nick,
    Thanks for pointing it out. I store a single column family and a single column for each key.
    Therefore, my understanding is nScannedRecs should match the number of keys in the table.
    Cheers,

    Julius

    Collapse
    #29761

    Nick Dimiduk
    Participant

    Your nScannedRecs is counting KeyValues returned, not rows. When you say you have 200 million records in the table, are you talking about rows, or KeyValues?

    Thanks,
    Nick

    Collapse
    #29757

    Sasha J
    Moderator

    Julius,
    I asked our developers take a loom on this.

    Thank you!
    Sasha

    Collapse
Viewing 5 replies - 1 through 5 (of 5 total)