The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

HBase Forum

HBase InternalScanner scan seems to be stuck in endless loop

  • #29732
    Julius Lerm

    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 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 {

    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() );
    InternalScanner scanner = env.getRegion().getScanner(scan);
    long sum = 0;

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

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

    if (nScannedRecs > 999999999999l) break;
    } while (hasMore);
    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;


  • Author
  • #29757
    Sasha J

    I asked our developers take a loom on this.

    Thank you!

    Nick Dimiduk

    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?


    Julius Lerm

    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.


    Julius Lerm


    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.




    Hi Julius,

    thanks for letting us know.


The forum ‘HBase’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.