Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
==========================================
- Coverage 83.65% 82.81% -0.85%
==========================================
Files 89 90 +1
Lines 5917 6022 +105
==========================================
+ Hits 4950 4987 +37
- Misses 967 1035 +68
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
hellais
left a comment
There was a problem hiding this comment.
This needs to be tested, but I believe that if we convert these tables to replicated tables, we will have to update the TRUNCATE citizenlab_flip to execute with alter_sync otherwise the INSERT operation will start running on the replicas before the TRUNCATE merge has completed running, leading to potentially duplicated data.
Given that these tables are very small, I'm also not sure we necessarily need a sharding key for them which probably simplifies things by not having a different ZK key. I saw a bug reported on the CH issue tracker mentioning that when that is the case there could be problems with TRUNCATE and EXCHANGE operations not converging: ClickHouse/ClickHouse#60489.
Thanks for flagging this. From what I understand the TRUNCATE can be made to operate synchronously, but there's another problem which is that if a replica drops offline for a long enough time, the EXCHANGE is not applied, and that node would get out of sync with the rest of the replicas.
There are two ways to mitigate this, one, is to swap the database engine to use ENGINE = Replicated, and the other is to ditch using an EXCHANGE atomic swap entirely and accept the empty-table window during the periodic update |
This avoids potential inconsistency with offline replicas, and uses a temporary table to store the new data before swapping the data cluster wide.
this harness verifies that a clustered clickhouse deployment applies the citizenlab updates correctly
|
There is actually another way to update the data without using the EXCHANGE .. ON CLUSTER semantics which is to use REPLACE PARTITION from a temporary table instead, which avoids potential issues with replicas that are down |
|
added clustered clickhouse harness to test exchange partition replicates correctly |
| # atomically -- readers on every replica see either the fully-old or | ||
| # fully-new data, never a mix or a gap, so there's no outage window on | ||
| # any node. alter_sync=3 waits only for currently *active* citizenlab | ||
| # replicas to confirm the swap, rather than alter_sync=2's "wait for |
There was a problem hiding this comment.
I think in reality we would want all replicas to converge before considering the task completed. If they don't converge then we ought to be showing an error, rather than silently swallowing it or hoping for the best.
There was a problem hiding this comment.
this task runs frequently and only skips a replica that is actually offline; when it comes online it converges. It's only to prevent this task from blocking if a replica has an outage due to hardware failure or maintenance window
| version: "3" | ||
| services: | ||
| clickhouse-01: | ||
| image: "clickhouse/clickhouse-server:25.2" |
There was a problem hiding this comment.
Our current server version is 24.8.6. Why are we using this specific version in here?
There was a problem hiding this comment.
this is pinned to production version now
|
replaced by #190 |
Similar to #185, the EXCHANGE here doesn't run ON CLUSTER, so the updates don't propagate to the rest of the nodes and could leave them pointing at a truncated table.