Skip to content

Commit a73bf87

Browse files
authored
HDDS-14982. [Docs] Snapshot deletion lifecycle (#373)
1 parent 382bafe commit a73bf87

7 files changed

Lines changed: 111 additions & 7 deletions

File tree

docs/03-core-concepts/03-namespace/02-buckets/04-layouts/02-file-system-optimized.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ To update the default layout when creating buckets, configure these properties i
7272
| `ozone.s3g.default.bucket.layout` | `OBJECT_STORE` | Defines the default layout for buckets created through the S3 API |
7373

7474
<!--
75-
For detailed technical information about the internal metadata structure and implementation, see the [File System Optimization System Internals](../../../../07-system-internals/07-features/01-filesystem-optimization.md) documentation.
76-
-->
75+
For detailed technical information about the internal metadata structure and implementation, see the [File System Optimization System Internals](../../../../system-internals/features/filesystem-optimization) documentation.
76+
-->

docs/05-administrator-guide/02-configuration/03-security/05-encryption/02-transparent-data-encryption.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ However, in buckets with `FILE_SYSTEM_OPTIMIZED` layout, some irregular S3 key
152152
names may be rejected or normalized, which can be undesired.
153153
154154
<!--
155-
See [Prefix based File System Optimization](../../../../07-system-internals/07-features/01-filesystem-optimization.md) for more information.
155+
See [Prefix based File System Optimization](../../../../system-internals/features/filesystem-optimization) for more information.
156156
-->
157157
158158
When accessing an S3G-enabled encrypted bucket:

docs/07-system-internals/01-components/01-ozone-manager/02-rocksdb-schema.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The exact column families and key encodings can evolve between Ozone releases; t
1212

1313
| Property | Value |
1414
| -------- | ----- |
15-
| Database directory | Configured by [`ozone.om.db.dirs`](../../../05-administrator-guide/02-configuration/99-appendix) (falls back to `ozone.metadata.dirs` if unset) |
15+
| Database directory | Configured by [`ozone.om.db.dirs`](../../../administrator-guide/configuration/appendix) (falls back to `ozone.metadata.dirs` if unset) |
1616
| On-disk name | `om.db` |
1717
| Engine | RocksDB with multiple column families |
1818

@@ -42,7 +42,7 @@ Used for buckets with **LEGACY** or **OBJECT_STORE** layout. Keys are stored und
4242

4343
### 3. File system optimized (FSO) layout
4444

45-
Used for buckets with **FILE_SYSTEM_OPTIMIZED** layout. Keys use volume ID, bucket ID, and parent object ID so directory operations (for example `ls`, rename) can avoid scanning full string paths. See also [Filesystem optimization](../../07-features/01-filesystem-optimization).
45+
Used for buckets with **FILE_SYSTEM_OPTIMIZED** layout. Keys use volume ID, bucket ID, and parent object ID so directory operations (for example `ls`, rename) can avoid scanning full string paths. See also [File System Optimized buckets](../../../core-concepts/namespace/buckets/layouts/file-system-optimized).
4646

4747
| Table name | Key format | Value type | Description |
4848
| ---------- | ---------- | ---------- | ----------- |
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
sidebar_label: Snapshot Deletion Lifecycle
3+
---
4+
5+
# Snapshot Deletion Lifecycle
6+
7+
This document describes the internal lifecycle of snapshot deletion in Apache Ozone, from the initial user request to the final physical removal of data and metadata.
8+
9+
The snapshot deletion process is divided into four main phases:
10+
11+
## 1. Request Phase: `OMSnapshotDeleteRequest`
12+
13+
* **Trigger:** User executes the command `ozone sh snapshot delete <bucket> <snapshot>`.
14+
* **Operation:**
15+
* The Ozone Manager (OM) receives the request and validates it.
16+
* The snapshot's status is updated to `SNAPSHOT_DELETED` in the `SnapshotInfoTable`.
17+
* The `deletionTime` is set to the current timestamp.
18+
* **Result:** This phase only "labels" the snapshot for deletion. It does not yet adjust the snapshot chain or reclaim any data. The snapshot remains in the system but is now a candidate for the background reclamation service.
19+
20+
## 2. Reclamation Phase: `SnapshotDeletingService`
21+
22+
* **Trigger:** A background service that runs periodically.
23+
* **Operation:**
24+
* The service identifies snapshots with the `SNAPSHOT_DELETED` status.
25+
* It processes the deleted snapshot's internal tracking tables: `deletedTable`, `deletedDirTable`, and `renamedTable`.
26+
* **Data Moving:** It moves entries from these tables to either:
27+
1. The **next active snapshot** in the chain (if one exists).
28+
2. The **Active Object Store (AOS)** if no subsequent snapshot exists.
29+
* **Settling:** Once all keys and directories for the snapshot have been successfully moved (i.e., the snapshot's deleted tables are empty), the service collects the snapshot's DB key into a "purge list".
30+
31+
## 3. Finalization Phase: `OMSnapshotPurgeRequest`
32+
33+
* **Trigger:** Triggered by the `SnapshotDeletingService` once a snapshot is fully "empty" (all keys reclaimed).
34+
* **Chain Adjustment (The Surgeon):** This is where the actual snapshot chain surgery occurs. The service updates the `previousSnapshotId` of the next snapshot in the chain to point to the deleted snapshot's predecessor, effectively "stitching" the chain back together.
35+
* **Deep Clean Flag:** It sets `setDeepClean(false)` on the next snapshots. This signals the `KeyDeletingService` that it can now perform a "deeper" cleanup because a snapshot in the middle of the chain has been removed, potentially uncovering more keys that are no longer referenced by any snapshot.
36+
* **Removal (The Janitor):** The snapshot record is removed from the `SnapshotInfoTable` cache, and the corresponding checkpoint directory on disk is deleted.
37+
38+
## 4. Persistence: `OMSnapshotPurgeResponse`
39+
40+
* **Operation:** The Ozone Manager double-buffer flushes the transaction to disk.
41+
* **Result:** The snapshot record is physically and permanently deleted from the RocksDB `snapshotInfoTable`.
42+
43+
---
44+
45+
## Summary of Roles
46+
47+
| Component | Role | Description |
48+
| :--- | :--- | :--- |
49+
| **`OMSnapshotDeleteRequest`** | The Labeler | Marks the snapshot for death by updating its status. |
50+
| **`SnapshotDeletingService`** | The Reclaimer | Moves the data references to the next snapshot or AOS. |
51+
| **`OMSnapshotPurgeRequest`** | The Surgeon & Janitor | Re-links the snapshot chain and deletes the physical records. |
52+
53+
![Apache Ozone Snapshot Deletion Lifecycle](snapshot_delete.png)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
draft: true
32
sidebar_label: Bucket Snapshot
43
---
54

65
# Bucket Snapshot System Internals
76

8-
**TODO:** File a subtask under [HDDS-9862](https://issues.apache.org/jira/browse/HDDS-9862) and complete this page or section.
7+
For detailed information on how snapshots are deleted internally, see the [Snapshot Deletion Lifecycle](./bucket-snapshot-deletion-lifecycle) page.
8+
5.58 MB
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
sidebar_label: Snapshot Deletion Lifecycle
3+
---
4+
5+
# Snapshot Deletion Lifecycle
6+
7+
This document describes the internal lifecycle of snapshot deletion in Apache Ozone, from the initial user request to the final physical removal of data and metadata.
8+
9+
The snapshot deletion process is divided into four main phases:
10+
11+
## 1. Request Phase: `OMSnapshotDeleteRequest`
12+
13+
* **Trigger:** User executes the command `ozone sh snapshot delete <bucket> <snapshot>`.
14+
* **Operation:**
15+
* The Ozone Manager (OM) receives the request and validates it.
16+
* The snapshot's status is updated to `SNAPSHOT_DELETED` in the `SnapshotInfoTable`.
17+
* The `deletionTime` is set to the current timestamp.
18+
* **Result:** This phase only "labels" the snapshot for deletion. It does not yet adjust the snapshot chain or reclaim any data. The snapshot remains in the system but is now a candidate for the background reclamation service.
19+
20+
## 2. Reclamation Phase: `SnapshotDeletingService`
21+
22+
* **Trigger:** A background service that runs periodically.
23+
* **Operation:**
24+
* The service identifies snapshots with the `SNAPSHOT_DELETED` status.
25+
* It processes the deleted snapshot's internal tracking tables: `deletedTable`, `deletedDirTable`, and `renamedTable`.
26+
* **Data Moving:** It moves entries from these tables to either:
27+
1. The **next active snapshot** in the chain (if one exists).
28+
2. The **Active Object Store (AOS)** (the main bucket) if no subsequent snapshot exists.
29+
* **Settling:** Once all keys and directories for the snapshot have been successfully moved (i.e., the snapshot's deleted tables are empty), the service collects the snapshot's DB key into a "purge list".
30+
31+
## 3. Finalization Phase: `OMSnapshotPurgeRequest`
32+
33+
* **Trigger:** Triggered by the `SnapshotDeletingService` once a snapshot is fully "empty" (all keys reclaimed).
34+
* **Chain Adjustment (The Surgeon):** This is where the actual snapshot chain surgery occurs. The service updates the `previousSnapshotId` of the next snapshot in the chain to point to the deleted snapshot's predecessor, effectively "stitching" the chain back together.
35+
* **Deep Clean Flag:** It sets `setDeepClean(false)` on the next snapshots. This signals the `KeyDeletingService` that it can now perform a "deeper" cleanup because a snapshot in the middle of the chain has been removed, potentially uncovering more keys that are no longer referenced by any snapshot.
36+
* **Removal (The Janitor):** The snapshot record is removed from the `SnapshotInfoTable` cache, and the corresponding checkpoint directory on disk is deleted.
37+
38+
## 4. Persistence: `OMSnapshotPurgeResponse`
39+
40+
* **Operation:** The Ozone Manager double-buffer flushes the transaction to disk.
41+
* **Result:** The snapshot record is physically and permanently deleted from the RocksDB `snapshotInfoTable`.
42+
43+
---
44+
45+
## Summary of Roles
46+
47+
| Component | Role | Description |
48+
| :--- | :--- | :--- |
49+
| **`OMSnapshotDeleteRequest`** | The Labeler | Marks the snapshot for death by updating its status. |
50+
| **`SnapshotDeletingService`** | The Reclaimer | Moves the data references to the next snapshot or AOS. |
51+
| **`OMSnapshotPurgeRequest`** | The Surgeon & Janitor | Re-links the snapshot chain and deletes the physical records. |

0 commit comments

Comments
 (0)