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

Allow backup+restore mutation with "in progress" status, disallow backup tables and parts have inconsistent structure #529

Closed
Slach opened this issue Oct 6, 2022 · 4 comments
Assignees
Milestone

Comments

@Slach
Copy link
Collaborator

Slach commented Oct 6, 2022

  • make hard links /var/lib/clickhouse/backup/backup_name/shadow/db/table/disk/part_name -> /var/lib/clickhouse/(data/db/table|store/uuid)/detached/part_name
  • maybe need SYSTEM STOP MERGES, SYSTEM RESTORE REPLICA for ReplicatedMergeTree
@Slach
Copy link
Collaborator Author

Slach commented Feb 13, 2023

Yet another idea:

  • save SELECT * FROM system.mutations WHERE is_done=0 into metadata/db/table_name.json
  • restore ReplicatedMergeTree as MergeTree, and create mutations_X.txt with ATTACH TABLE
  • poll SELECT * system.mutations WHERE is_done=0
  • ALTER TABLE tmp_table ATTACH PART FROM TABLE orig_table to allow replicate mutated parts

@Slach Slach modified the milestones: 2.2.0, 2.3.0 Feb 13, 2023
@Slach
Copy link
Collaborator Author

Slach commented May 13, 2023

need create properly test case to test behavior

to avoid race-condition state, I tried something like

CREATE TABLE t1 (v UInt64, m UInt64) ENGINE=MergeTree() PARTITION BY v ORDER BY v;
INSERT INTO t1 SELECT number, number FROM numbers(99);

SYSTEM STOP MERGES;
ALTER TABLE t1 MODIFY COLUMN m String;

SELECT type, active, count() FROM system.parts_columns WHERE table='t1' AND column='m' GROUP BY type, active FORMAT Vertical;

but ALTER TABLE is stuck when MERGES stop ...
and executed synchronously when i run it before SYSTEM STOP MERGES...
if even we will try to run both ALTER + STOP MERGES parellel, i don't sure ALTER will stop or stuck ...

Need ideas how to make possible ALTER TABLE ... in progress state and make ALTER TABLE ... FREEZE ..
without generate gigabytes of data!

@Slach
Copy link
Collaborator Author

Slach commented May 14, 2023

ATTACH PART works perfectly , ATTACH TABLE doesn't need

but need to add backup_mutations was added to allow us backup and restore in progress mutations

@Slach Slach changed the title Use ATTACH TABLE ... instead of ATTACH PART to allow restore tables where mutation "in progress" and parts have inconsistent structure Allow backup+restore mutation with "in progress" status, disallow backup tables and parts have inconsistent structure May 19, 2023
@Slach
Copy link
Collaborator Author

Slach commented May 19, 2023

to disallow backup inconsistent types in data parts

need execute

SELECT database, table, column, uniqExact(type) AS column_types
FROM system.parts_columns
WHERE active
GROUP BY database, table, column
HAVING column_types>1 

and add separate config option clickhouse->check_parts_columns and CLI parameter --check-parts-columns to create and create_remote command

@Slach Slach closed this as completed in 94116ec May 24, 2023
@Slach Slach modified the milestones: 2.3.0, 2.2.7 May 25, 2023
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