Skip to content

Commit b61dbc0

Browse files
authored
Merge pull request #1130 from Altinity/bugfix/antalya-25.8/system_drop_filesystem_cache_on_cluster
Fix SYSTEM DROP FILESYSTEM CACHE ON CLUSTER
2 parents 10f1a23 + aebebf5 commit b61dbc0

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)
@@ -519,6 +525,9 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti
519525
case Type::END:
520526
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown SYSTEM command");
521527
}
528+
529+
if (queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
530+
formatOnCluster(ostr, settings);
522531
}
523532

524533

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)