ClickHouse / ClickHouse/clickhouse-go

Query with HTTP protocol fails, if the user does not have permission to change max_execution_time

Open
#1,107 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
3.3k
Forks
680
Avg merge
2d 3h
Merged PRs (30d)
14

Description

### Describe the bug

The driver sets `max_execution_time` to the remaining time of the context timeout. But if the user does not have permission to change the `max_execution_time` setting, the query will fail. I believe this is the part that does it: https://github.com/ClickHouse/clickhouse-go/blob/72fb7127808fece20452dfcde0eb351c7164a195/context.go#L175-L182
For some reason this only happens when you use the http protocol. Maybe the context is only used there.

A solution is to give the user the permission, but sometimes that is out of your control. There should be a way to not change any settings, but currently there is not.

### Steps to reproduce
1. Create a user with readonly = 1 (Can't change settings)
2. Set protocol to clickhouse.http
3. Try any query, it will fail with `DB::Exception: Cannot modify 'max_execution_time' setting in readonly mode. (READONLY)`

### Configuration
#### Environment
* Client version: v2.14.1
* Language version: 1.21
* OS: Linux

#### ClickHouse server
* ClickHouse Server version: 23.8.2.7

Clickhouse user settings:
```xml



1
20

```

Driver settings:
```go
conn := clickhouse.OpenDB(&clickhouse.Options{
Addr: "127.0.0.1:8123",
Auth: clickhouse.Auth{
Database: "default",
Username: "username",
Password: "secret",
},
Protocol: clickhouse.http,
DialTimeout: time.Second * 30,
})
```

Contributor guide

Open the contributing guide

Research direction

Read context.go lines 175-182 and trace how HTTP requests apply context timeout settings. Reproduce with a readonly ClickHouse user and the HTTP protocol; done when queries no longer fail because max_execution_time cannot be modified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.