Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear the data directories before restoring CH #246

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions astacus/coordinator/plugins/clickhouse/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .disks import Disks
from .steps import (
AttachMergeTreePartsStep,
ClearDisksStep,
ClickHouseManifestStep,
CollectObjectStorageFilesStep,
CollectTieredStorageResultsStep,
Expand Down Expand Up @@ -184,6 +185,7 @@ def get_restore_steps(self, *, context: OperationContext, req: RestoreRequest) -
ClickHouseManifestStep(),
RetrieveMacrosStep(clients=clients),
ListDatabaseReplicasStep(),
ClearDisksStep(disks=disks), # clear any leftovers from previous attempts
RestoreReplicatedDatabasesStep(
clients=clients,
replicated_databases_zookeeper_path=self.replicated_databases_zookeeper_path,
Expand Down
17 changes: 17 additions & 0 deletions astacus/coordinator/plugins/clickhouse/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,23 @@ async def run_step(self, cluster: Cluster, context: StepsContext) -> DatabasesRe
return get_databases_replicas(manifest.replicated_databases, server_macros)


@dataclasses.dataclass
class ClearDisksStep(Step[Sequence[ipc.NodeResult]]):
"""
Request to remove all data on all ClickHouse disks.

Used to remove remnants of previous failed restore attempts.
"""

disks: Disks

async def run_step(self, cluster: Cluster, context: StepsContext) -> Sequence[ipc.NodeResult]:
root_globs = ["/".join((*disk.path_parts, "store/**/*")) for disk in self.disks.disks]
node_request = ipc.SnapshotClearRequest(root_globs=root_globs)
start_results = await cluster.request_from_nodes("clear", method="post", caller="ClearDisksStep", req=node_request)
return await cluster.wait_successful_results(start_results=start_results, result_class=ipc.NodeResult)


@dataclasses.dataclass
class SyncDatabaseReplicasStep(Step[None]):
zookeeper_client: ZooKeeperClient
Expand Down
Loading