From b53fc06947ffbf1f4e78ff2a506392df5c475da7 Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Mon, 10 Nov 2025 09:12:42 +0100 Subject: [PATCH 1/3] Fix SYSTEM DROP FILESYSTEM CACHE 'cache' ON CLUSTER 'cluster' --- src/Parsers/ASTSystemQuery.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Parsers/ASTSystemQuery.cpp b/src/Parsers/ASTSystemQuery.cpp index 992971dd1ac8..00925e561219 100644 --- a/src/Parsers/ASTSystemQuery.cpp +++ b/src/Parsers/ASTSystemQuery.cpp @@ -163,7 +163,13 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti print_keyword("SYSTEM") << " "; print_keyword(typeToString(type)); - if (!cluster.empty()) + + std::unordered_set queries_with_on_cluster_at_end = { + Type::DROP_FILESYSTEM_CACHE, + Type::SYNC_FILESYSTEM_CACHE, + }; + + if (!queries_with_on_cluster_at_end.contains(type) && !cluster.empty()) formatOnCluster(ostr, settings); switch (type) @@ -519,6 +525,9 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti case Type::END: throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown SYSTEM command"); } + + if (queries_with_on_cluster_at_end.contains(type) && !cluster.empty()) + formatOnCluster(ostr, settings); } From 7061fbc3c0938ab8a69b57cc39a7f20e41939793 Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Mon, 10 Nov 2025 09:32:33 +0100 Subject: [PATCH 2/3] Add test --- ...drop_filesystem_cache_on_cluster.reference | 0 ...system_drop_filesystem_cache_on_cluster.sh | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference create mode 100755 tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.sh diff --git a/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference b/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.sh b/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.sh new file mode 100755 index 000000000000..8f40316ac5d1 --- /dev/null +++ b/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Tags: no-fasttest, no-parallel, no-object-storage, no-random-settings + +# set -x + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + + +disk_name="${CLICKHOUSE_TEST_UNIQUE_NAME}" +$CLICKHOUSE_CLIENT -m --query """ +DROP TABLE IF EXISTS test; +CREATE TABLE test (a Int32, b String) +ENGINE = MergeTree() ORDER BY tuple() +SETTINGS disk = disk(name = '$disk_name', type = cache, max_size = '100Ki', path = ${CLICKHOUSE_TEST_UNIQUE_NAME}, disk = s3_disk); + +INSERT INTO test SELECT 1, 'test'; +""" + +$CLICKHOUSE_CLIENT --query """ +SYSTEM SYNC FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost'; +""" + +$CLICKHOUSE_CLIENT --query """ +SYSTEM DROP FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost'; +""" + +$CLICKHOUSE_CLIENT --query """ +DROP TABLE IF EXISTS test; +""" From aebebf500c5c00a00a8ab81ab43ea8aac03b715f Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Tue, 11 Nov 2025 09:44:31 +0100 Subject: [PATCH 3/3] Fix test --- .../03643_system_drop_filesystem_cache_on_cluster.reference | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference b/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference index e69de29bb2d1..1444d39d9578 100644 --- a/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference +++ b/tests/queries/0_stateless/03643_system_drop_filesystem_cache_on_cluster.reference @@ -0,0 +1,2 @@ +localhost 9000 0 0 0 +localhost 9000 0 0 0