Skip to content

Conversation

@scotwells
Copy link
Contributor

The previous clickhouse deployment was setup to run as a single node cluster preventing us from having a highly available deployment.

The database schema has been adjusted to create a replicated database so that Clickhouse will automatically replicate schema changes and data between replicas.

Important

This schema change is a breaking change so the environments will be re-created.

I've also adjusted the ordering of audit logs to use the timestamp as a secondary sort column so we can maintain strict ordering of audit logs. There's still benefits in maintaining the hourly bucketing so Clickhouse can skip over entire hours of data through indexes. The apiserver has been updated to use the new ordering.

The migration script will now wait for all replicas in the cluster to come up before executing migrations.


Relates to datum-cloud/enhancements#536

The previous clickhouse deployment was setup to run as a single node
cluster preventing us from having a highly available deployment.

The database schema has been adjusted to create a replicated database so
that Clickhouse will automatically replicate schema changes and data
between replicas.

This schema change is a breaking change so the environments will be
re-created.

I've also adjusted the ordering of audit logs to use the timestamp as a
secondary sort column so we can maintain strict ordering of audit logs.
There's still benefits in maintaining the hourly bucketing so Clickhouse
can skip over entire hours of data through indexes. The apiserver has
been updated to use the new ordering.

The migration script will now wait for all replicas in the cluster to
come up before executing migrations.
Need operational visibility into Clickhouse Keeper so we can monitor the
component and understand replication delay between cluster replicas.
ecv
ecv previously approved these changes Jan 19, 2026
Were using a replicated database now. Need to account for some replicas reporting the same metrics.
These pod disruption budgets ensure the clickhouse system is able to
maintain quorum by only letting a single replica of the database and the
keeper instance be offline at any given time.
@scotwells
Copy link
Contributor Author

Had an incident happen in production over the weekend after we deployed this change. To help mitigate the same issue in the future, I added resource requirements, topology spread constraints, and pod disruption budgets for the workloads to ensure they're hardened for production.

I also had to replace the table engine with the ReplicatedReplacingMergeTree table engine so that data is replicated across replicas. I misunderstood the Clickhouse documentation originally and thought that using a replicated database engine was enough to configure replication of DDL schema changes and the underlying data.

Also adjusted the audit log pipeline dashboard to account for replication being enabled now.

@scotwells scotwells requested a review from ecv January 20, 2026 15:03
@scotwells scotwells merged commit e67f7dc into main Jan 20, 2026
4 checks passed
@scotwells scotwells deleted the feat/create-highly-available-replicated-database branch January 20, 2026 17:56
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.

3 participants