Skip to content

Adjust ClickHouse configuration to disable query_views_log#4365

Open
LordSimal wants to merge 2 commits into
getsentry:masterfrom
LordSimal:master
Open

Adjust ClickHouse configuration to disable query_views_log#4365
LordSimal wants to merge 2 commits into
getsentry:masterfrom
LordSimal:master

Conversation

@LordSimal
Copy link
Copy Markdown

image

As you can see in the screenshot above clickhouse doesn't cleanup its views_log tables automatically, see https://clickhouse.com/docs/operations/system-tables/query_views_log

ClickHouse does not delete data from the table automatically.

I don't think this is necessary in a "normal" self-hosted environment unless someone needs to debug clickhouse.

This of course does not truncate the existing tables, that maybe needs to be added to the install script.
@aldy505 what do you think?

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@LordSimal
Copy link
Copy Markdown
Author

LordSimal commented Jun 4, 2026

The _0 table was created with the https://github.com/getsentry/self-hosted/releases/tag/25.9.0 update and therefore a clickhouse version upgrade. Maybe a cleanup script should be added on install to remove all old, unnecessary clickhouse tables.

Primarily for me this is about query_log_0 and query_views_log_0

@aldy505
Copy link
Copy Markdown
Collaborator

aldy505 commented Jun 4, 2026

Yeah sure, let's include some deletion queries on the install script. ClickHouse have lightweight deletes, so I think it'll be fine: https://clickhouse.com/docs/guides/developer/lightweight-delete

@LordSimal
Copy link
Copy Markdown
Author

To get this working/testing properly via ./install/cleanup-clickhouse.sh i had to add

source install/dc-detect-version.sh

at the top of that file but after that it seems to have worked.

root@scarecrow:~/sentry# ./install/cleanup-clickhouse.sh
Cleaning up ClickHouse query log tables ...
▶ Initializing Docker|Podman Compose ...
docker compose --ansi never run --pull=never --rm

 Container sentry-self-hosted-clickhouse-1 Starting
 Container sentry-self-hosted-clickhouse-1 Started
 Container sentry-self-hosted-clickhouse-1 Waiting
 Container sentry-self-hosted-clickhouse-1 Healthy
Dropping system.query_log_0 ...
Dropping system.query_views_log_0 ...
Truncating system.query_log and system.query_views_log ...

Copy link
Copy Markdown
Collaborator

@aldy505 aldy505 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants