You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "James Taylor (JIRA)" <ji...@apache.org> on 2016/08/25 15:48:21 UTC

[jira] [Created] (HBASE-16503) Delay in preScannerNext > rpcTimeout causes scan to fail

James Taylor created HBASE-16503:
------------------------------------

             Summary: Delay in preScannerNext > rpcTimeout causes scan to fail
                 Key: HBASE-16503
                 URL: https://issues.apache.org/jira/browse/HBASE-16503
             Project: HBase
          Issue Type: Bug
    Affects Versions: 0.98.21
            Reporter: James Taylor


In HBase 0.98, a delay in the preScannerNext coprocessor hook of greater than the RPC timeout causes the scan to fail. This can happen in Phoenix when a large aggregate is performed without statistics enabled, in which case the work is done during preScannerNext. The same test works fine in HBase 1.1.

{code}
package org.apache.hadoop.hbase.client.coprocessor;

import static org.junit.Assert.assertNull;

import java.io.IOException;
import java.util.List;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HConnection;
import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.junit.Test;


public class TestDelayPreScannerNext {
    private static final long RPC_TIMEOUT = 2000;
    private static final String TABLE_NAME = "foo";
    
    @Test
    public void testPreScannerNextDelayCausesScanToFail() throws Exception {
        Configuration conf = HBaseConfiguration.create();
        conf.setLong("hbase.rpc.timeout", RPC_TIMEOUT);
        HBaseTestingUtility utility = new HBaseTestingUtility(conf);
        utility.startMiniCluster();
        HTableDescriptor desc = utility.createTableDescriptor(TABLE_NAME);
        desc.addCoprocessor(DelayPreScannerNextRegionObserver.class.getName());
        utility.createTable(desc, new byte[][]{});
        HConnection connection = HConnectionManager.createConnection(conf);
        HTableInterface table = connection.getTable(TABLE_NAME);
        ResultScanner scanner = table.getScanner(new Scan());
        assertNull(scanner.next());
    }
    
    public static class DelayPreScannerNextRegionObserver extends SimpleRegionObserver {
        @Override
        public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
                final InternalScanner s, final List<Result> results,
                final int limit, final boolean hasMore) throws IOException {
            try {
                Thread.sleep(RPC_TIMEOUT * 2);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new IOException(e);
            }
            return super.preScannerNext(c, s, results, limit, hasMore);
        }
    }
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)