Skip to content

Skip using 'ON CLUSTER' in case of DB Engine is 'Replicated'#119

Open
911limbo wants to merge 1 commit intoflyway:mainfrom
911limbo:clickhouse-skip-on-cluster-for-replicated-db
Open

Skip using 'ON CLUSTER' in case of DB Engine is 'Replicated'#119
911limbo wants to merge 1 commit intoflyway:mainfrom
911limbo:clickhouse-skip-on-cluster-for-replicated-db

Conversation

@911limbo
Copy link
Copy Markdown

Summary

ClickHouse throws the following error when executing DDL with ON CLUSTER inside a database created with ENGINE = Replicated(...):
Code: 48. DB::Exception: ON CLUSTER is not allowed for Replicated database

Replicated databases already propagate DDL statements automatically via the database engine, therefore adding ON CLUSTER is invalid.

What this PR does

This change detects whether the target database uses the Replicated engine (via system.databases) and skips adding ON CLUSTER in that case.

The check is executed using the dedicated system connection to avoid issues when the target database does not yet exist.

Why this is needed

Flyway adds ON CLUSTER to DDL statements when a cluster is configured.

However, if the target database is created with ENGINE = Replicated(...),
ClickHouse does not allow using ON CLUSTER, because DDL replication
is already handled by the database engine itself.

As a result, migrations fail with:

Code: 48. DB::Exception: ON CLUSTER is not allowed for Replicated database

Compatibility

  • No behavior change for non-Replicated databases

  • No change for users who do not configure a cluster

  • Safe for databases that are not yet created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant