ClickHouse / ClickHouse/odbc-bridge

Intermittent `no connection to the server` error using PostgreSQL

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
4
Forks
4
PR merge metrics
No merged PRs in 30d

Description

After upgrading clickhouse-odbc-bridge to 25.1.5.31, we are getting the following error intermittently (~2% of all queries using ODBC tables):
```
Code: 86. DB::Exception: Received error from remote server http://127.0.0.1:9018/?use_connection_pooling=1&version=1&connection_string=DSN%3Dmy_postgres_db&max_block_size=65409. HTTP status code: 500 'Internal Server Error', body length: 1910 bytes, body: 'std::exception. Code: 1001, type: nanodbc::database_error, e.what() = contrib/nanodbc/nanodbc/nanodbc.cpp:1985: 22023: no connection to the server
;
no connection to the server
, Stack trace (when copying this message, always include the lines below):

0. ./build_docker/./contrib/nanodbc/nanodbc/nanodbc.cpp:554: nanodbc::database_error::database_error(void*, short, String const&) @ 0x0000000006cbbaab
1. ./build_docker/./contrib/nanodbc/nanodbc/nanodbc.cpp:1985: nanodbc::statement::statement_impl::just_execute_direct(nanodbc::connection&, String const&, nanodbc::batch_ops const&, long, nanodbc::statement&, void*) @ 0x0000000006cbde59
2. ./build_docker/./contrib/nanodbc/nanodbc/nanodbc.cpp:1944: nanodbc::execute(nanodbc::connection&, String const&, long, long) @ 0x0000000006cbcedb
3. ./build_docker/./programs/odbc-bridge/ODBCSource.cpp:28: DB::ODBCSource::ODBCSource(std::shared_ptr, String const&, DB::Block const&, unsigned long) @ 0x000000000458bfcd
4. ./contrib/llvm-project/libcxx/include/__memory/construct_at.h:41: DB::ODBCHandler::handleRequest(DB::HTTPServerRequest&, DB::HTTPServerResponse&, StrongTypedef const&) @ 0x000000000458798b
5. ./build_docker/./src/Server/HTTP/HTTPServerConnection.cpp:71: DB::HTTPServerConnection::run() @ 0x0000000006a86a8a
6. ./build_docker/./base/poco/Net/src/TCPServerConnection.cpp:40: Poco::Net::TCPServerConnection::start() @ 0x0000000009265887
7. ./build_docker/./base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x0000000009265cd9
8. ./build_docker/./base/poco/Foundation/src/ThreadPool.cpp:205: Poco::PooledThread::run() @ 0x0000000009232f3b
9. ./base/poco/Foundation/src/Thread_POSIX.cpp:335: Poco::ThreadImpl::runnableEntry(void*) @ 0x000000000923163d
10. ? @ 0x00007fc94abd7ac3
11. ? @ 0x00007fc94ac698c0
(version 25.1.5.31 (official build))
': (in file/uri http://127.0.0.1:9018/?use_connection_pooling=1&version=1&connection_string=DSN%3Dmy_postgres_db&max_block_size=65409): While executing BinaryRowInputFormat: While executing ODBC. (RECEIVED_ERROR_FROM_REMOTE_IO_SERVER) (version 25.8.11.66 (official build))"
```

The errors are not correlated with specific queries or tables. This error goes away after rolling back clickhouse-odbc-bridge to `24.8.14.39`.

# Deployment information
- clickhouse-odbc-bridge version: `25.1.5.31`
- clickhouse-server version: `25.8.11.66`, also reproduced on `24.8.14.39`
- PostgreSQL version: 15.12
- PostgreSQL deployed on Amazon RDS

```
# odbc.ini
[my_postgres_db]
Description =PostgreSQL ODBC
Driver =PostgreSQL Unicode
Database =my_postgres_db
Servername =.rds.amazonaws.com
UserName =
Password =
Port =5432
Protocol =15.10
ReadOnly =Yes
SSLmode =require
Pqopt =sslrootcert=/sonrai/conf/global-bundle.pem

# odbcinst.ini
[PostgreSQL Unicode]
Description=PostgreSQL ODBC driver (Unicode version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1

# Dockerfile
FROM clickhouse/clickhouse-server:25.8.11.66

RUN apt-get update \
&& apt-get install -y clickhouse-odbc-bridge="25.1.5.31" odbc-postgresql odbcinst unixodbc \
&& rm -rf /var/lib/apt/lists/*
```

Contributor guide

Open the contributing guide

Research direction

Start by comparing clickhouse-odbc-bridge 25.1.5.31 with 24.8.14.39 around programs/odbc-bridge/ODBCSource.cpp and the nanodbc statement-execution frame in the report. Reproduce the intermittent failure using the supplied PostgreSQL 15.12/RDS and connection-pooling configuration. Done means the regression is explained and the bridge no longer intermittently reports that the server has no connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, docker, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.