Skip to content

Commit 1d9c74a

Browse files
Backport #91304 to 25.3: Fix SYSTEM DROP FILESYSTEM CACHE ON CLUSTER
1 parent 4878869 commit 1d9c74a

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/Parsers/ASTSystemQuery.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti
150150

151151
print_keyword("SYSTEM") << " ";
152152
print_keyword(typeToString(type));
153-
if (!cluster.empty())
153+
154+
std::unordered_set<Type> queries_with_on_cluster_at_end = {
155+
Type::DROP_FILESYSTEM_CACHE,
156+
Type::SYNC_FILESYSTEM_CACHE,
157+
};
158+
159+
if (!queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
154160
formatOnCluster(ostr, settings);
155161

156162
switch (type)
@@ -489,6 +495,9 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti
489495
case Type::END:
490496
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown SYSTEM command");
491497
}
498+
499+
if (queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
500+
formatOnCluster(ostr, settings);
492501
}
493502

494503

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
localhost 9000 0 0 0
2+
localhost 9000 0 0 0
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# Tags: no-fasttest, no-parallel, no-object-storage, no-random-settings
3+
4+
# set -x
5+
6+
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
7+
# shellcheck source=../shell_config.sh
8+
. "$CUR_DIR"/../shell_config.sh
9+
10+
11+
disk_name="${CLICKHOUSE_TEST_UNIQUE_NAME}"
12+
$CLICKHOUSE_CLIENT -m --query """
13+
DROP TABLE IF EXISTS test;
14+
CREATE TABLE test (a Int32, b String)
15+
ENGINE = MergeTree() ORDER BY tuple()
16+
SETTINGS disk = disk(name = '$disk_name', type = cache, max_size = '100Ki', path = ${CLICKHOUSE_TEST_UNIQUE_NAME}, disk = s3_disk);
17+
18+
INSERT INTO test SELECT 1, 'test';
19+
"""
20+
21+
$CLICKHOUSE_CLIENT --query """
22+
SYSTEM SYNC FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost';
23+
"""
24+
25+
$CLICKHOUSE_CLIENT --query """
26+
SYSTEM DROP FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost';
27+
"""
28+
29+
$CLICKHOUSE_CLIENT --query """
30+
DROP TABLE IF EXISTS test;
31+
"""

0 commit comments

Comments
 (0)