Skip to content
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

An obscure error in the HTTP protocol when using compression #1150

Closed
vitalyisaev2 opened this issue Dec 1, 2023 · 2 comments · Fixed by #1230 or #1286
Closed

An obscure error in the HTTP protocol when using compression #1150

vitalyisaev2 opened this issue Dec 1, 2023 · 2 comments · Fixed by #1230 or #1286
Assignees
Labels

Comments

@vitalyisaev2
Copy link

vitalyisaev2 commented Dec 1, 2023

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
@jkaflik jkaflik self-assigned this Dec 1, 2023
@wade-liwei
Copy link

how do you resolve the problem?

@jkaflik
Copy link
Contributor

jkaflik commented Jan 24, 2024

@wade-liwei what is your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants