Skip to content

Commit

Permalink
clickhouse: account for dropped KeeperMap tables
Browse files Browse the repository at this point in the history
If the table was dropped the table path still exists but the data ZNode
still exists.  This leads to an error in backup
  • Loading branch information
joelynch committed Sep 25, 2024
1 parent 68467c6 commit 330d74c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion astacus/coordinator/plugins/clickhouse/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ async def run_step(self, cluster: Cluster, context: StepsContext) -> Sequence[Ke
for child in children:
keeper_map_table_path = os.path.join(self.keeper_map_path_prefix, child)
data_path = os.path.join(keeper_map_table_path, "data")
data = await connection.get_children_with_data(data_path)
try:
data = await connection.get_children_with_data(data_path)
except NoNodeError:
logger.warning("ZNode %s is missing, table was dropped. Skipping", data_path)
continue

tables.append(
KeeperMapTable(
name=child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ async def setup_cluster_content(clients: Sequence[HttpClickHouseClient], use_nam
await clients[0].execute(b"INSERT INTO default.memory VALUES (123, 'foo')")
await clients[0].execute(b"CREATE FUNCTION `linear_equation_\x80` AS (x, k, b) -> k*x + b")
if await is_engine_available(clients[0], TableEngine.KeeperMap):
# add and drop a table with KeeperMap engine. This leaves some metadata in ZooKeeper that we want to ignore.
await clients[0].execute(
b"CREATE TABLE default.keeper_map_dropped (key UInt32, value String) ENGINE = KeeperMap('keeper_map_dropped') PRIMARY KEY key"
)
await clients[0].execute(b"DROP TABLE default.keeper_map_dropped")
# add a table to backup
await clients[0].execute(
b"CREATE TABLE default.keeper_map (key UInt32, value String) ENGINE = KeeperMap('keeper_map') PRIMARY KEY key"
)
Expand Down

0 comments on commit 330d74c

Please sign in to comment.