Skip to content

Commit 86ff256

Browse files
Backport #91304 to 25.11: Fix SYSTEM DROP FILESYSTEM CACHE ON CLUSTER
1 parent a57721c commit 86ff256

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
@@ -163,7 +163,13 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti
163163

164164
print_keyword("SYSTEM") << " ";
165165
print_keyword(typeToString(type));
166-
if (!cluster.empty())
166+
167+
std::unordered_set<Type> queries_with_on_cluster_at_end = {
168+
Type::DROP_FILESYSTEM_CACHE,
169+
Type::SYNC_FILESYSTEM_CACHE,
170+
};
171+
172+
if (!queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
167173
formatOnCluster(ostr, settings);
168174

169175
switch (type)
@@ -523,6 +529,9 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti
523529
case Type::END:
524530
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown SYSTEM command");
525531
}
532+
533+
if (queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
534+
formatOnCluster(ostr, settings);
526535
}
527536

528537

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)