Skip to content

host failed to respond #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kyofin opened this issue Apr 30, 2020 · 5 comments · Fixed by #515
Closed

host failed to respond #452

Kyofin opened this issue Apr 30, 2020 · 5 comments · Fixed by #515
Assignees
Labels
Milestone

Comments

@Kyofin
Copy link

Kyofin commented Apr 30, 2020

ru.yandex.clickhouse.except.ClickHouseUnknownException: ClickHouse exception, code: 1002, host: cdh06, port: 8123; cdh06:8123 failed to respond

@iceyung
Copy link

iceyung commented May 13, 2020

I have the same problem as you. At present, this error is reported by httpclient used by jdbc itself;
The critical point of survival of keep-alive, it may happen that the client thinks that the current connection is available, but the server has closed the current connection;
We temporarily disabled the long connection of jdbc httpclient, or we can also encapsulate the retry mechanism to avoid this problem:
E.g ClickHouseStatementImpl-> getInputStream:

HttpPost post = new HttpPost(uri);
post.setEntity(requestEntity);
post.setHeader("Connection", "close");

Whether this problem is the problem of httpclient, hope to analyze it concretely

@Kyofin
Copy link
Author

Kyofin commented Jun 10, 2020

I have the same problem as you. At present, this error is reported by httpclient used by jdbc itself;
The critical point of survival of keep-alive, it may happen that the client thinks that the current connection is available, but the server has closed the current connection;
We temporarily disabled the long connection of jdbc httpclient, or we can also encapsulate the retry mechanism to avoid this problem:
E.g ClickHouseStatementImpl-> getInputStream:

HttpPost post = new HttpPost(uri);
post.setEntity(requestEntity);
post.setHeader("Connection", "close");

Whether this problem is the problem of httpclient, hope to analyze it concretely

It does not work when i modiy the code like your recommand.

The same problem still appear when i batch insert Bulk data in clickhouse using jdbc.

@iceyung
Copy link

iceyung commented Jun 12, 2020

I have the same problem as you. At present, this error is reported by httpclient used by jdbc itself;
The critical point of survival of keep-alive, it may happen that the client thinks that the current connection is available, but the server has closed the current connection;
We temporarily disabled the long connection of jdbc httpclient, or we can also encapsulate the retry mechanism to avoid this problem:
E.g ClickHouseStatementImpl-> getInputStream:

HttpPost post = new HttpPost(uri);
post.setEntity(requestEntity);
post.setHeader("Connection", "close");

Whether this problem is the problem of httpclient, hope to analyze it concretely

It does not work when i modiy the code like your recommand.

The same problem still appear when i batch insert Bulk data in clickhouse using jdbc.

We got this error when selecting. I don’t know much about the scenario you are using, maybe you use the packet capture tool(eg:wireshark) to see the connection status.

@iceyung
Copy link

iceyung commented Jun 12, 2020

ClickHouseStatementImpl-> sendStream :

void sendStream(Writer writer, HttpEntity content) throws ClickHouseException {
        HttpEntity entity = null;
        try {

            URI uri = buildRequestUri(writer.getSql(), null, writer.getAdditionalDBParams(), writer.getRequestParams(), false);
            uri = followRedirects(uri);

            content = applyRequestBodyCompression(content);

            HttpPost httpPost = new HttpPost(uri);
            httpPost.setEntity(content);
          //add ?
            httpPost.setHeader("Connection", "close");
            HttpResponse response = client.execute(httpPost);
            entity = response.getEntity();
            checkForErrorAndThrow(entity, response);
        } catch (ClickHouseException e) {
            throw e;
        } catch (Exception e) {
            throw ClickHouseExceptionSpecifier.specify(e, properties.getHost(), properties.getPort());
        } finally {
            EntityUtils.consumeQuietly(entity);
        }
    }

@plinyar
Copy link

plinyar commented Jul 16, 2020

We have similar cases. Sometimes we get error "ru.yandex.clickhouse.except.ClickHouseUnknownException: ClickHouse exception, code: 1002, host: ..., port: ..; host:port failed to respond". It is raised in 1-4 milliseconds after request (in our case it is batch insert into TinyLog table, see call stack below). Our cnn string has the following query param: ?socket_timeout=90000, we use connection pooling. A retry in 3-5 seconds of the same action always succeeds.
Clickhouse version: 20.5.2.7
Jdbc driver: ru.yandex.clickhouse:clickhouse-jdbc:0.2.4

at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.getException(ClickHouseExceptionSpecifier.java:88)
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:55)
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:24)
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:800)
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:778)
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeBatch(ClickHousePreparedStatementImpl.java:363)
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeBatch(ClickHousePreparedStatementImpl.java:348)
at io.ebean.datasource.delegate.PreparedStatementDelegator.executeBatch(PreparedStatementDelegator.java:357)

@zhicwu zhicwu added the bug label Dec 29, 2020
@zhicwu zhicwu added this to the 0.2.5 release milestone Dec 29, 2020
@zhicwu zhicwu self-assigned this Jan 18, 2021
@zhicwu zhicwu modified the milestones: 0.2.5 release, 0.2.6 release Jan 26, 2021
@zhicwu zhicwu closed this as completed Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants