Skip to content

Commit f48ebac

Browse files
authored
Merge pull request #914 from Altinity/backports/25.3.6/79369
25.3.6 Backport of ClickHouse#79369 -- Ignore parse error in system.distributed_ddl_queue
2 parents c7b4958 + 00773a6 commit f48ebac

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/Storages/System/StorageSystemDDLWorkerQueue.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ namespace Setting
2929
extern const SettingsUInt64 max_query_size;
3030
}
3131

32+
namespace ErrorCodes
33+
{
34+
extern const int SYNTAX_ERROR;
35+
}
36+
3237
enum class Status : uint8_t
3338
{
3439
INACTIVE,
@@ -62,7 +67,7 @@ ColumnsDescription StorageSystemDDLWorkerQueue::getColumnsDescription()
6267
{"entry_version", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>()), "Version of the entry."},
6368
{"initiator_host", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()), "Host that initiated the DDL operation."},
6469
{"initiator_port", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt16>()), "Port used by the initiator."},
65-
{"cluster", std::make_shared<DataTypeString>(), "Cluster name."},
70+
{"cluster", std::make_shared<DataTypeString>(), "Cluster name, empty if not determined."},
6671
{"query", std::make_shared<DataTypeString>(), "Query executed."},
6772
{"settings", std::make_shared<DataTypeMap>(std::make_shared<DataTypeString>(), std::make_shared<DataTypeString>()), "Settings used in the DDL operation."},
6873
{"query_create_time", std::make_shared<DataTypeDateTime>(), "Query created time."},
@@ -85,8 +90,23 @@ static String clusterNameFromDDLQuery(ContextPtr context, const DDLTask & task)
8590

8691
String description = fmt::format("from {}", task.entry_path);
8792
ParserQuery parser_query(end, settings[Setting::allow_settings_after_format_in_insert]);
88-
ASTPtr query = parseQuery(
89-
parser_query, begin, end, description, settings[Setting::max_query_size], settings[Setting::max_parser_depth], settings[Setting::max_parser_backtracks]);
93+
ASTPtr query;
94+
95+
try
96+
{
97+
query = parseQuery(
98+
parser_query, begin, end, description, settings[Setting::max_query_size], settings[Setting::max_parser_depth], settings[Setting::max_parser_backtracks]);
99+
}
100+
catch (const Exception & e)
101+
{
102+
LOG_INFO(getLogger("StorageSystemDDLWorkerQueue"), "Failed to determine cluster");
103+
if (e.code() == ErrorCodes::SYNTAX_ERROR)
104+
{
105+
/// ignore parse error and present available information
106+
return "";
107+
}
108+
throw;
109+
}
90110

91111
String cluster_name;
92112
if (const auto * query_on_cluster = dynamic_cast<const ASTQueryWithOnCluster *>(query.get()))

0 commit comments

Comments
 (0)