clickhouse-go icon indicating copy to clipboard operation
clickhouse-go copied to clipboard

An obscure error in the HTTP protocol when using compression

Open vitalyisaev2 opened this issue 2 years ago • 2 comments

When trying to access ClickHouse server with invalid credentials using HTTP protocol with LZ4 Compression enabled, an unclear error occurs. Consider this small example:

package main

import (
	"fmt"
	"github.com/ClickHouse/clickhouse-go/v2"
)

func makeOptions(compression bool) *clickhouse.Options {
	opts := &clickhouse.Options{
		Addr: []string{"localhost:8123"},
		Auth: clickhouse.Auth{
			Database: "dqrun",
			Username: "crab",
			Password: "qwerty12345", // Wrong password
		},
		Protocol: clickhouse.HTTP,
	}

	if compression {
		opts.Compression = &clickhouse.Compression{
			Method: clickhouse.CompressionLZ4,
		}
	}

	return opts
}

func main() {
	conn1 := clickhouse.OpenDB(makeOptions(false))
	err := conn1.Ping()
	fmt.Printf("Without compression:\n%v\n\n", err)

	conn2 := clickhouse.OpenDB(makeOptions(true))
	err = conn2.Ping()
	fmt.Printf("With compression:\n%v\n\n", err)

	return
}

Without compression the error is straightforward:

clickhouse [execute]:: 403 code: Code: 516. DB::Exception: crab: Authentication failed: password is incorrect, or there is no user with such name. (AUTHENTICATION_FAILED) (version 23.4.2.11 (official build))

Otherwise user gets obscure error resembling protocol corruption:

clickhouse [execute]:: failed to read the response: read: read next block: data size should be 0 < 980316009 < 134217728

Configuration

Environment

  • Client version: github.com/ClickHouse/clickhouse-go 1.5.4
  • Language version: go1.21.3 linux/amd64
  • OS: Ubuntu 20

ClickHouse server

  • ClickHouse Server version: 23.4.2.11

vitalyisaev2 avatar Dec 01 '23 12:12 vitalyisaev2

how do you resolve the problem?

ChainCoderX avatar Jan 24 '24 10:01 ChainCoderX

@wade-liwei what is your issue?

jkaflik avatar Jan 24 '24 11:01 jkaflik