-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-13003. [POC] Snapshot Defragmentation to reduce storage footprint #8954
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
Closed
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
8f1b164
HDDS-13003. [POC] Snapshot Defragmentation to reduce storage footprint
smengcl ad3ed61
[split] Add new OM layout feature SNAPSHOT_DEFRAGMENTATION (doesn't d…
smengcl f81e5b7
Make `RDBSstFileWriter` public to be used in defrag service.
smengcl e15a62d
Implement `delete(key)` in `RDBSstFileWriter`.
smengcl c04d67a
Add config `ozone.snapshot.defrag.service.timeout`, `ozone.snapshot.d…
smengcl 160434b
Rename term: compact -> defrag
smengcl ac58394
[split] HDDS-13009. Implement SnapshotDefragService POC.
smengcl 3de45ba
[split] Implement manual trigger of snapshot defrag. e.g. `ozone admi…
smengcl ab9d67e
Add tests (for debugging)
smengcl 5bf6646
[split] yaml: TODO: Add OM_SLD_DB_CHECKPOINT_DIR field
smengcl d9ace6b
[drop][dev] Disable WAL archival
smengcl 1270359
SDS: Write diff to defragged DB directly instead of writing to SST fi…
smengcl 410ba6e
[dev] Disable WAL in write options for testing
smengcl 41241fe
[dev] Update native library handling in Ozone build and shell
smengcl 41abbc1
[dev] Add debug log for failed System.loadLibrary call
smengcl 61a7fac
Update default values in OmSnapshotLocalData constructor
smengcl fb700d0
[dev] testUpdateYaml to set fields in .yaml before triggering defrag
smengcl 2f1cb67
Remove TestSnapshotDefragService test class
smengcl 737416b
Reorder constant definition in OMConfigKeys
smengcl e301d7c
[dev] Update compose/ozone volumes/profiles and config defaults for l…
smengcl 173ea8e
om: Use triggerSnapshotDefragOnce for snapshot defrag manual triggering
smengcl f1e5def
SDS: Do not fall back to full defrag on inc defrag error
smengcl 8124405
SDS: Clean up, add TODOs
smengcl 026f74f
SDS: Fix extractKeyFromPath for FSO (hack).
smengcl af7dc32
Rename CHECKPOINT_STATE_DEFRAGED_DIR -> CHECKPOINT_STATE_DEFRAGGED_DIR
smengcl f08ebe9
Update TestSnapshotDefragService2 for FSO buckets and config tuning
smengcl 6cb7420
[split] freon RandomKeyGenerator to handle existing volumes and buckets
smengcl 420323f
[dev] Update key comparison logic in SnapshotDiffManager to count mod…
smengcl bcab08c
Make RocksCheckpoint and related methods public
smengcl 60fbe52
[split] Handle STAND_ALONE replication type in QuotaUtil (was printin…
smengcl fb5fa37
[split] TODO that we should disable db.snapshots creation for scm and…
smengcl 09a381a
Remove TestOmSnapshotDefrag integration test
smengcl a527b67
Update docker-compose.yaml
smengcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...admin/src/main/java/org/apache/hadoop/ozone/admin/om/TriggerSnapshotDefragSubCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.admin.om; | ||
|
|
||
| import java.util.concurrent.Callable; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; | ||
| import picocli.CommandLine; | ||
|
|
||
| /** | ||
| * Handler of ozone admin om triggerSnapshotDefrag command. | ||
| */ | ||
| @CommandLine.Command( | ||
| name = "triggerSnapshotDefrag", | ||
| description = "Triggers the Snapshot Defragmentation Service to run " + | ||
| "immediately. This command manually initiates the snapshot " + | ||
| "defragmentation process which compacts snapshot data and removes " + | ||
| "fragmentation to improve storage efficiency.", | ||
| mixinStandardHelpOptions = true, | ||
| versionProvider = HddsVersionProvider.class | ||
| ) | ||
| public class TriggerSnapshotDefragSubCommand implements Callable<Void> { | ||
|
|
||
| @CommandLine.ParentCommand | ||
| private OMAdmin parent; | ||
|
|
||
| @CommandLine.Option( | ||
| names = {"-id", "--service-id"}, | ||
| description = "Ozone Manager Service ID" | ||
| ) | ||
| private String omServiceId; | ||
|
|
||
| @CommandLine.Option( | ||
| names = {"-host", "--service-host"}, | ||
| description = "Ozone Manager Host" | ||
| ) | ||
| private String omHost; | ||
|
|
||
| @CommandLine.Option( | ||
| names = {"--no-wait"}, | ||
| description = "Do not wait for the defragmentation task to complete. " + | ||
| "The command will return immediately after triggering the task.", | ||
| defaultValue = "false" | ||
| ) | ||
| private boolean noWait; | ||
|
|
||
| @Override | ||
| public Void call() throws Exception { | ||
| boolean forceHA = false; | ||
|
|
||
| try (OzoneManagerProtocol client = parent.createOmClient(omServiceId, omHost, forceHA)) { | ||
| System.out.println("Triggering Snapshot Defragmentation Service..."); | ||
| boolean result = client.triggerSnapshotDefrag(noWait); | ||
|
|
||
| if (noWait) { | ||
| System.out.println("Snapshot defragmentation task has been triggered " + | ||
| "successfully and is running in the background."); | ||
| } else { | ||
| if (result) { | ||
| System.out.println("Snapshot defragmentation completed successfully."); | ||
| } else { | ||
| System.out.println("Snapshot defragmentation task failed or was " + | ||
| "interrupted."); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
| System.err.println("Failed to trigger snapshot defragmentation: " + | ||
| e.getMessage()); | ||
| throw e; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,11 +426,21 @@ public final class OMConfigKeys { | |
| "ozone.snapshot.deleting.limit.per.task"; | ||
| public static final int SNAPSHOT_DELETING_LIMIT_PER_TASK_DEFAULT = 10; | ||
|
|
||
| // Snapshot defragmentation service configuration | ||
| public static final String SNAPSHOT_DEFRAG_LIMIT_PER_TASK = | ||
| "ozone.snapshot.defrag.limit.per.task"; | ||
| public static final int SNAPSHOT_DEFRAG_LIMIT_PER_TASK_DEFAULT = 1; | ||
|
|
||
| public static final String OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL = | ||
| "ozone.snapshot.filtering.service.interval"; | ||
| public static final String | ||
| OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL_DEFAULT = "60s"; | ||
|
|
||
| public static final String OZONE_SNAPSHOT_DEFRAG_SERVICE_INTERVAL = | ||
| "ozone.snapshot.defrag.service.interval"; | ||
| public static final String | ||
| OZONE_SNAPSHOT_DEFRAG_SERVICE_INTERVAL_DEFAULT = "60s"; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: May need to increase this interval if snapshotDiff is taking long. Does interval countdown start only after the service run ends? I vaguely remember that is the case. Need to double check |
||
|
|
||
| public static final String | ||
| OZONE_SNAPSHOT_CHECKPOINT_DIR_CREATION_POLL_TIMEOUT = | ||
| "ozone.om.snapshot.checkpoint.dir.creation.poll.timeout"; | ||
|
|
@@ -558,13 +568,12 @@ public final class OMConfigKeys { | |
|
|
||
| public static final String OZONE_OM_SNAPSHOT_DIFF_REPORT_MAX_PAGE_SIZE | ||
| = "ozone.om.snapshot.diff.max.page.size"; | ||
| public static final int OZONE_OM_SNAPSHOT_DIFF_REPORT_MAX_PAGE_SIZE_DEFAULT = 1000; | ||
|
|
||
| public static final String OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES | ||
| = "ozone.om.snapshot.db.max.open.files"; | ||
| public static final int OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES_DEFAULT | ||
| = 100; | ||
| public static final int OZONE_OM_SNAPSHOT_DIFF_REPORT_MAX_PAGE_SIZE_DEFAULT | ||
| = 1000; | ||
|
|
||
| public static final String OZONE_OM_SNAPSHOT_DIFF_THREAD_POOL_SIZE | ||
| = "ozone.om.snapshot.diff.thread.pool.size"; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: the interval can be set to 2 or 3 later