[ 
https://issues.apache.org/jira/browse/KYLIN-3891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16795641#comment-16795641
 ] 

zhao jintao commented on KYLIN-3891:
------------------------------------

I search this exception use google,and I find that the httpclient of jdbc need 
retry when face NoHttpResponseException.
[apache 
stack|https://stackoverflow.com/questions/10570672/get-nohttpresponseexception-for-load-testing/10680629#10680629]

After I add retry  configuation in KylinClient.java of httpClient, It work fine 
in my jdbc test. 

httpClient.setHttpRequestRetryHandler((exception, executionCount, context) -> {
            if (executionCount > 3) {
                logger.warn("Maximum tries reached for client http pool ");
                return false;
            }

            if (exception instanceof NoHttpResponseException     
//NoHttpResponseException 重试
//                    || exception instanceof ConnectTimeoutException //连接超时重试
//              || exception instanceof SocketTimeoutException    
//响应超时不重试,避免造成业务数据不一致
                    ) {
                logger.warn("NoHttpResponseException on " + executionCount + " 
call");
                return true;
            }
            return false;
        });

I use this jdbc client in FineReort system, jdbc client connect SLB,SLB connect 
kylin.But I find that if I restart kylin, sometimes  jdbc client response 502 
httpcode from SLB。
I use this jdbc client in FineReort system, jdbc client connect SLB,SLB connect 
kylin.But I find that if I restart kylin, sometimes  jdbc client accept 502 
response from SLB。

This is FineReport log:

        at org.apache.kylin.jdbc.KylinConnection.<init>(KylinConnection.java:69)
        at 
org.apache.kylin.jdbc.KylinJdbcFactory.newConnection(KylinJdbcFactory.java:77)
        at 
org.apache.kylin.jdbc.shaded.org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138)
        at 
com.fr.third.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1461)
        at 
com.fr.third.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1525)
        at 
com.fr.third.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2099)
Caused by: java.io.IOException: POST failed, error code 502 and response: 
<!DOCTYPE html>^M

Does any one meet this same problem?

> Kylin jdbc throws NoHttpResponseException
> -----------------------------------------
>
>                 Key: KYLIN-3891
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3891
>             Project: Kylin
>          Issue Type: Bug
>          Components: Driver - JDBC
>    Affects Versions: v2.5.2
>         Environment: Huawei FusionInsight
>            Reporter: zhao jintao
>            Priority: Major
>              Labels: easyfix
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Hi Team;
> When I use kylin jdbc, I find that jdbc throws NoHttpResponseException. 
> Then I  do jdbc test cases in "DriverTest.java", I use one jdbc connection 
> query 20 times, each time first wait 20 minutes. Unfortunately, I also find 
> that jdbc also throws NoHttpResponseException.
> This is my test code:
>         try {
>             for (int j = 0; j < 20; j++) {
>                 Thread.sleep(1000*20);
>                 Statement state = conn.createStatement();
>                 ResultSet resultSet = state.executeQuery("select count(*) 
> from KYLIN_SALES ;");
>                 printResultSetMetaData(resultSet);
>                 printResultSet(resultSet);
>                 resultSet.close();
>             }
>         } catch (InterruptedException e){
>             e.printStackTrace();
>         }
> This is NoHttpResponseException: 
> java.sql.SQLException: Error while executing SQL "select count(*) from 
> KYLIN_SALES ;": java.sql.SQLException: 
> org.apache.http.NoHttpResponseException: The target server failed to respond
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
>       at org.apache.kylin.jdbc.DriverTest.testHttpClient(DriverTest.java:299)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>       at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>       at 
> com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.lang.RuntimeException: java.sql.SQLException: 
> org.apache.http.NoHttpResponseException: The target server failed to respond
>       at org.apache.kylin.jdbc.KylinMeta.prepareAndExecute(KylinMeta.java:115)
>       at 
> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
>       ... 24 more
> Caused by: java.sql.SQLException: org.apache.http.NoHttpResponseException: 
> The target server failed to respond
>       at org.apache.kylin.jdbc.KylinResultSet.execute(KylinResultSet.java:71)
>       at 
> org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:630)
>       at org.apache.kylin.jdbc.KylinMeta.prepareAndExecute(KylinMeta.java:111)
>       ... 26 more
> Caused by: org.apache.http.NoHttpResponseException: The target server failed 
> to respond
>       at 
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:95)
>       at 
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:62)
>       at 
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
>       at 
> org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
>       at 
> org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
>       at 
> org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:191)
>       at 
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
>       at 
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
>       at 
> org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:715)
>       at 
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:520)
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
>       at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
>       at 
> org.apache.kylin.jdbc.KylinClient.executeKylinQuery(KylinClient.java:407)
>       at org.apache.kylin.jdbc.KylinClient.executeQuery(KylinClient.java:363)
>       at org.apache.kylin.jdbc.KylinResultSet.execute(KylinResultSet.java:69)
>       ... 28 more
> Process finished with exit code -1



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to