You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/altinity-kb-useful-queries/detached-parts.md
+22-9Lines changed: 22 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,17 @@ keywords:
9
9
- clickhouse drop partition
10
10
---
11
11
12
+
Detached parts act like the “Recycle Bin” in Windows. When ClickHouse deems some data unneeded—often during internal reconciliations at server startup—it moves the data to the detached area instead of deleting it immediately.
13
+
14
+
Recovery: If you’re missing data due to misconfiguration or an error (such as connecting to the wrong ZooKeeper), check the detached parts. The missing data might be recoverable through manual intervention.
15
+
16
+
Cleanup: Otherwise, clean up the detached parts periodically to free disk space.
17
+
18
+
Regarding detached parts and the absence of an automatic cleanup feature within ClickHouse: this was a deliberate decision, as there is a possibility that data may appear there due to a bug in ClickHouse's code, a hardware error (such as a memory error or disk failure), etc. In such cases, automatic cleanup is not desirable.
19
+
12
20
Blog article - https://altinity.com/blog/understanding-detached-parts-in-clickhouse
13
21
22
+
14
23
ClickHouse® users should monitor for detached parts and act quickly when they appear. Here is what the different statuses of detached parts mean:
15
24
16
25
1. Parts are renamed to **ignored** if they were found during ATTACH together with other, bigger parts that cover the same blocks of data, i.e. they were already merged into something else.
@@ -38,6 +47,19 @@ GROUP BY database, table, reason
38
47
ORDER BY database ASC, table ASC, reason ASC
39
48
```
40
49
50
+
### drop detached
51
+
The DROP DETACHED command in ClickHouse is used to remove parts or partitions that have previously been detached (i.e., moved to the detached directory and forgotten by the server). The syntax is:
52
+
53
+
```
54
+
ALTER TABLE table_name [ON CLUSTER cluster] DROP DETACHED PARTITION|PART ALL|partition_expr
55
+
```
56
+
57
+
This command removes the specified part or all parts of the specified partition from the detached directory. For more details on how to specify the partition expression, see the documentation on how to set the partition expression DROP DETACHED PARTITION|PART.
58
+
59
+
Note: You must have the allow_drop_detached setting enabled to use this command allow_drop_detached
60
+
61
+
### drop all script
62
+
41
63
Here is a query that can help with investigations. It looks for active parts containing the same data blocks as the detached parts. It
42
64
generates commands to drop the detached parts.
43
65
@@ -77,12 +99,3 @@ covered-by-broken - that means that ClickHouse during initialization of replica
77
99
78
100
The list of DETACH_REASONS: https://github.com/ClickHouse/ClickHouse/blob/master/src/Storages/MergeTree/MergeTreePartInfo.h#L163
79
101
80
-
## More notes on ClickHouseDetachedParts
81
-
82
-
Detached parts act like the “Recycle Bin” in Windows. When ClickHouse deems some data unneeded—often during internal reconciliations at server startup—it moves the data to the detached area instead of deleting it immediately.
83
-
84
-
Recovery: If you’re missing data due to misconfiguration or an error (such as connecting to the wrong ZooKeeper), check the detached parts. The missing data might be recoverable through manual intervention.
85
-
86
-
Cleanup: Otherwise, clean up the detached parts periodically to free disk space.
87
-
88
-
Regarding detached parts and the absence of an automatic cleanup feature within ClickHouse: this was a deliberate decision, as there is a possibility that data may appear there due to a bug in ClickHouse's code, a hardware error (such as a memory error or disk failure), etc. In such cases, automatic cleanup is not desirable.
0 commit comments