suharev7 / clickhouse-rs

Asynchronous ClickHouse client library for Rust programming language.
MIT License
324 stars 121 forks source link

Detect TCP disconnects #168

Closed dmitryvk closed 1 year ago

dmitryvk commented 2 years ago

In case of a TCP disconnect (i.e., server-side graceful TCP shutdown), query result stream should return error instead of just hanging indefinitely.

Before this change, it would hang due to ClickhouseTransport::poll_next returning Pending upon reaching EOF on socket stream.

In order to properly handle TCP disconnect:

1) ClickhouseTransport should detect this condition and return None to signal that there are no more packets 2) BlockStream should handle end of packets:

1) Return error from Stream::next() 2) Prevent reuse of connection in pool

suharev7 commented 1 year ago

Thanks a lot.