ClickHouse/ch-go

"got rows without target" when creating database on cluster

Closed this issue · 2 comments

Describe the bug

I'm using ch-go to creating database and tables. Bug ch-go would failed instantly after creating database, and after failure I can see err logs in clickhouse console with database created.

logs from clickhouse:

2023.09.06 17:30:56.757502 [ 50 ] {} <Error> TCPHandler: Code: 33. DB::Exception: Cannot read all data. Bytes read: 0. Bytes expected: 3. (CANNOT_READ_ALL_DATA), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c604bf7 in /usr/bin/clickhouse
1. DB::Exception::Exception<unsigned long&, String>(int, FormatStringHelperImpl<std::type_identity<unsigned long&>::type, std::type_identity<String>::type>, unsigned long&, String&&) @ 0x00000000073116d4 in /usr/bin/clickhouse
2. DB::ReadBuffer::readStrict(char*, unsigned long) @ 0x00000000073115d7 in /usr/bin/clickhouse
3. DB::TCPHandler::receiveUnexpectedHello() @ 0x0000000013119d72 in /usr/bin/clickhouse
4. DB::TCPHandler::receivePacket() @ 0x0000000013114f20 in /usr/bin/clickhouse
5. DB::TCPHandler::runImpl() @ 0x000000001310bcbe in /usr/bin/clickhouse
6. DB::TCPHandler::run() @ 0x000000001311e839 in /usr/bin/clickhouse
7. Poco::Net::TCPServerConnection::start() @ 0x0000000015b104d4 in /usr/bin/clickhouse
8. Poco::Net::TCPServerDispatcher::run() @ 0x0000000015b116d1 in /usr/bin/clickhouse
9. Poco::PooledThread::run() @ 0x0000000015c47f07 in /usr/bin/clickhouse
10. Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000015c461dc in /usr/bin/clickhouse
11. ? @ 0x00007f49373cf609 in ?
12. ? @ 0x00007f49372f4133 in ?

logs from ch-go's zap-logger:

decode block: raw block: got rows without target

Steps to reproduce

I've make a smallest reproducible project at here.

  1. docker compose up -d
  2. go test ./

Conclusion: If the statement has result, then you must set Result field of proto.Result struct.

Now everything works as expected:

图片

Here comes another question: It's not convenient if the user want to drop some column of the result. In the example, I don't want num_hosts_remaining and num_hosts_active field, expecting ch-go to not to deserialize them.

ernado commented

Currently there is no way to drop a subset of columns.
To do this, we actually still need to de-serialize them, because there is no way to just "skip" columns on protocol level.

Currently I suggest using https://github.com/ClickHouse/clickhouse-go for this until someone will come up with a more elegant way to handle it.