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

Ability to restore schema by running ATTACH TABLE statement for --schema, if data already present #868

Open
Slach opened this issue Mar 8, 2024 Discussed in #867 · 1 comment
Assignees
Milestone

Comments

@Slach
Copy link
Collaborator

Slach commented Mar 8, 2024

Discussed in #867

Originally posted by tadus21 March 8, 2024
Hey,
We have a use case where we store data in ReplicatedMergeTree table which keeps it in different disks according to the TTL.
We noticed that in scenario where:
DISK_A stores table metadata and data, DISK_B stores just data and by accident DISK_A is lost
we can just manually move sql file with the attach table statement to DISK_A/clickhouse/metadata directory (if we have it backed up). After db restart, the table will be attached to the ClickHouse with all the parts from DISK_B present without manually moving them to detach folder and reattaching. This saves time making replica healthy because then ZK only have to restore data from DISK_A from the another replica.
I noticed that in backup metadata folder, table creation query have UUID in it so in theory backup tool could recreate the same scenario by running ATTACH TABLE instead of CREATE TABLE? Would it make sense to provide additional flag to restore command which would define whether ATTACH or CREATE statement should be ran for schema restoration? I seen that something similar is happening when restore_as_attach is set to true, but its only relevant when on data restoration flow.
If this make sense I would gladly contribute on this feature.

@Slach
Copy link
Collaborator Author

Slach commented Mar 8, 2024

ATTACH TABLE
already requires overwrite metatada/db/table.sql

@Slach Slach added this to the 2.6.0 milestone Mar 8, 2024
@Slach Slach self-assigned this Mar 8, 2024
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

No branches or pull requests

1 participant