Skip to content

Properly handle terminated connection by the server and fix CI #226

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

Open
wants to merge 4 commits into
base: async-await
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
image: clickhouse/clickhouse-server
ports:
- 9000:9000
env:
CLICKHOUSE_SKIP_USER_SETUP: 1
steps:
- uses: actions/checkout@v3
- name: Build
Expand All @@ -45,6 +47,7 @@ jobs:
-v ./extras/ci/overrides.xml:/etc/clickhouse-server/config.d/overrides.xml
-e CH_SSL_CERTIFICATE=/etc/clickhouse-server/config.d/server.crt
-e CH_SSL_PRIVATE_KEY=/etc/clickhouse-server/config.d/server.key
-e CLICKHOUSE_SKIP_USER_SETUP=1
--network host
--rm
--detach
Expand Down Expand Up @@ -72,6 +75,7 @@ jobs:
-v ./extras/ci/overrides.xml:/etc/clickhouse-server/config.d/overrides.xml
-e CH_SSL_CERTIFICATE=/etc/clickhouse-server/config.d/server.crt
-e CH_SSL_PRIVATE_KEY=/etc/clickhouse-server/config.d/server.key
-e CLICKHOUSE_SKIP_USER_SETUP=1
--network host
--rm
--detach
Expand Down
9 changes: 9 additions & 0 deletions src/io/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ impl Stream for ClickhouseTransport {
}

if *this.done {
// We still have may have something in buffer, since the client may read something
// first, and only after the server will close the connection, likely in case of
// exception, let's try to parse it here
if !this.rd.is_empty() {
if let Poll::Ready(ret) = this.try_parse_msg()? {
return Poll::Ready(ret.map(Ok));
}
}

return Poll::Ready(None);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl ClientHandle {
}

self.inner = h;
self.context.server_info = info.unwrap();
self.context.server_info = info.ok_or(Error::Other("Missing Hello/Exception packet".into()))?;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ mod test {
#[test]
fn test_size_of() {
use std::mem;
assert_eq!(56, mem::size_of::<[Value; 1]>());
assert_eq!(64, mem::size_of::<[Value; 1]>());
}

#[test]
Expand Down