Skip to content

system.distributed_ddl_queue parses the queries that it finds in ZK #75011

@SaltTan

Description

@SaltTan

Company or project name

No response

Describe the unexpected behaviour

When querying system.distributed_ddl_queue ClickHouse tries to parse the DDDL statement and throws errors when it is not possible.
Normally exceptions shouldn't happen as queries are parsed before being submitted into the DDDL queue, but it is still possible.
For example, after a downgrade system.distributed_ddl_queue will be enable to parse queries if they used syntax that was unavailable in older releases.

How to reproduce

In my example here I ran a drop table query and then changed the query manually in ZK.
Now selects from system.distributed_ddl_queue fail.

It is not clear why system.distributed_ddl_queue should parse the queries that it finds in ZK.


SELECT *
FROM system.zookeeper
WHERE path = '/clickhouse/task_queue/ddl/'

Query id: 212cd645-d32e-4d38-8a3a-925e0dcb37db

   ┌─name────────────────────┬─value────────────────────┬─path─────────────────────────────────────────────────┐
1. │ query-0000000001 │ version: 5
query: drop TABLEa default.qq ON CLUSTER mycluster
hosts: ['ch1%2549:9000']
initiator: ch1%2549:9000
tracing: 00000000-0000-0000-0000-000000000000
0

0
initial_query_id: 58958efa-d685-4221-a311-a93216c358b1  │ /clickhouse/task_queue/ddl/                          │
2. │ active                  │                          │ /clickhouse/task_queue/ddl/query-0000000001          │
3. │ finished                │                          │ /clickhouse/task_queue/ddl/query-0000000001          │
4. │ ch1%2549:9000           │ 0                        │ /clickhouse/task_queue/ddl/query-0000000001/finished │
   └─────────────────────────┴──────────────────────────┴──────────────────────────────────────────────────────┘


SELECT *
FROM system.distributed_ddl_queue

Query id: 68e977f6-41d5-4c7e-8d94-ad4d9d8f6e6b

Elapsed: 0.002 sec.

Received exception from server (version 24.12.3):
Code: 62. DB::Exception: Received from localhost:9000. DB::Exception: Syntax error (from /clickhouse/task_queue/ddl/query-0000000001): failed at position 6 ('TABLEa'): TABLEa default.qq ON CLUSTER segmented. Expected one of: DATABASE, ALL, VIEW, DICTIONARY, TEMPORARY, TABLE, FUNCTION, WORKLOAD, RESOURCE, NAMED COLLECTION, INDEX, USER, ROLE, SETTINGS PROFILE, PROFILE, ROW POLICY, POLICY, QUOTA. (SYNTAX_ERROR)

Expected behavior

I would expect system.distributed_ddl_queue to display the content of the DDDL queue without trying to interpret it.

Error message and/or stacktrace

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    unexpected behaviourResult is unexpected, but not entirely wrong at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions