Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clickhouse/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</logger>
<query_thread_log remove="remove"/>
<query_log remove="remove"/>
<query_views_log remove="remove"/>
<text_log remove="remove"/>
<trace_log remove="remove"/>
<metric_log remove="remove"/>
Expand Down
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ source install/check-minimum-requirements.sh
# Upgrading clickhouse needs to come first before turning things off, since we need the old clickhouse image
# in order to determine whether or not the clickhouse version needs to be upgraded.
source install/upgrade-clickhouse.sh
source install/cleanup-clickhouse.sh
source install/update-docker-images.sh
source install/turn-things-off.sh
source install/create-docker-volumes.sh
Expand Down
39 changes: 39 additions & 0 deletions install/cleanup-clickhouse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
echo "${_group}Cleaning up ClickHouse query log tables ..."

if [ "$CONTAINER_ENGINE" = "podman" ]; then
ps_command="$dc ps"
else
ps_command="$dc ps -a"
fi

drop_clickhouse_system_table_if_exists() {
local table="$1"
local table_exists

table_exists=$($dc exec clickhouse clickhouse-client -q "SELECT count() FROM system.tables WHERE database = 'system' AND name = '$table'")

if [[ "$table_exists" == "1" ]]; then
echo "Dropping system.$table ..."
$dc exec clickhouse clickhouse-client -q "DROP TABLE system.$table"
else
echo "system.$table does not exist, skipping."
fi
}

truncate_clickhouse_query_log_tables() {
echo "Truncating system.query_log and system.query_views_log ..."
$dc exec clickhouse clickhouse-client --multiquery -q "
SYSTEM FLUSH LOGS;
TRUNCATE TABLE IF EXISTS system.query_log;
TRUNCATE TABLE IF EXISTS system.query_views_log;
"
}

if $ps_command | grep -q clickhouse; then
start_service_and_wait_ready clickhouse
drop_clickhouse_system_table_if_exists query_log_0
drop_clickhouse_system_table_if_exists query_views_log_0
truncate_clickhouse_query_log_tables
fi

echo "${_endgroup}"
Loading