-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-12533. Offline repair command for generic rocksDB compaction #8039
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5fc0448
HDDS-12310. Repair command to perform compaction on rocksDB
98d1062
CHeckstyle fix
2e1d042
Checkstyle fix
29f7d1d
HDDS-12533. Offline repair command for generic rocksDB compaction
6b68801
Add ldb sub command for repair
422ba81
Improve messsages
5b8e4e3
Improve help messsages
f1d88d0
Punctuation and space fixes
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
35 changes: 35 additions & 0 deletions
35
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/LDBRepair.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,35 @@ | ||
| /* | ||
| * 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.repair.ldb; | ||
|
|
||
| import org.apache.hadoop.hdds.cli.RepairSubcommand; | ||
| import org.kohsuke.MetaInfServices; | ||
| import picocli.CommandLine; | ||
|
|
||
| /** | ||
| * Ozone Repair CLI for ldb. | ||
| */ | ||
| @CommandLine.Command(name = "ldb", | ||
| subcommands = { | ||
| RocksDBManualCompaction.class | ||
| }, | ||
| description = "Operational tool to repair ldb.") | ||
| @MetaInfServices(RepairSubcommand.class) | ||
| public class LDBRepair implements RepairSubcommand { | ||
|
|
||
| } |
90 changes: 90 additions & 0 deletions
90
...ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.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,90 @@ | ||
| /* | ||
| * 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.repair.ldb; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.hdds.utils.IOUtils; | ||
| import org.apache.hadoop.hdds.utils.db.managed.ManagedCompactRangeOptions; | ||
| import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksDB; | ||
| import org.apache.hadoop.ozone.debug.RocksDBUtils; | ||
| import org.apache.hadoop.ozone.repair.RepairTool; | ||
| import org.apache.hadoop.util.Time; | ||
| import org.rocksdb.ColumnFamilyDescriptor; | ||
| import org.rocksdb.ColumnFamilyHandle; | ||
| import org.rocksdb.RocksDBException; | ||
| import picocli.CommandLine; | ||
|
|
||
| /** | ||
| * Tool to perform compaction on a table. | ||
| */ | ||
| @CommandLine.Command( | ||
| name = "compact", | ||
| description = "CLI to compact a column-family in the DB while the service is offline.\n" + | ||
| "Note: If om.db is compacted with this tool then it will negatively impact " + | ||
| "the Ozone Manager's efficient snapshot diff.", | ||
| mixinStandardHelpOptions = true, | ||
| versionProvider = HddsVersionProvider.class | ||
| ) | ||
| public class RocksDBManualCompaction extends RepairTool { | ||
|
|
||
| @CommandLine.Option(names = {"--db"}, | ||
| required = true, | ||
| description = "Database File Path") | ||
| private String dbPath; | ||
|
|
||
| @CommandLine.Option(names = {"--column-family", "--column_family", "--cf"}, | ||
| required = true, | ||
| description = "Column family name") | ||
| private String columnFamilyName; | ||
|
|
||
| @Override | ||
| public void execute() throws Exception { | ||
| List<ColumnFamilyHandle> cfHandleList = new ArrayList<>(); | ||
| List<ColumnFamilyDescriptor> cfDescList = RocksDBUtils.getColumnFamilyDescriptors( | ||
| dbPath); | ||
|
|
||
| try (ManagedRocksDB db = ManagedRocksDB.open(dbPath, cfDescList, cfHandleList)) { | ||
| ColumnFamilyHandle cfh = RocksDBUtils.getColumnFamilyHandle(columnFamilyName, cfHandleList); | ||
| if (cfh == null) { | ||
| throw new IllegalArgumentException(columnFamilyName + | ||
| " is not in a column family in DB for the given path."); | ||
| } | ||
|
|
||
| info("Running compaction on " + columnFamilyName); | ||
| long startTime = Time.monotonicNow(); | ||
| if (!isDryRun()) { | ||
| ManagedCompactRangeOptions compactOptions = new ManagedCompactRangeOptions(); | ||
| compactOptions.setBottommostLevelCompaction(ManagedCompactRangeOptions.BottommostLevelCompaction.kForce); | ||
| db.get().compactRange(cfh, null, null, compactOptions); | ||
| } | ||
| long duration = Time.monotonicNow() - startTime; | ||
| info("Compaction completed in " + duration + "ms."); | ||
|
|
||
| } catch (RocksDBException exception) { | ||
| error("Exception: " + exception); | ||
| String errorMsg = "Failed to compact RocksDB for the given path: " + dbPath + | ||
| ", column family: " + columnFamilyName; | ||
| throw new IOException(errorMsg, exception); | ||
| } finally { | ||
| IOUtils.closeQuietly(cfHandleList); | ||
| } | ||
| } | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/package-info.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,21 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| /** | ||
| * OM related repair tools. | ||
| */ | ||
| package org.apache.hadoop.ozone.repair.ldb; |
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.
Uh oh!
There was an error while loading. Please reload this page.