Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-14 Thread via GitHub


Tejaskriya commented on PR #8039:
URL: https://github.com/apache/ozone/pull/8039#issuecomment-2724030359

   @jojochuang @errose28 thanks for the reviews and the approvals!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-14 Thread via GitHub


Tejaskriya merged PR #8039:
URL: https://github.com/apache/ozone/pull/8039


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-13 Thread via GitHub


errose28 commented on code in PR #8039:
URL: https://github.com/apache/ozone/pull/8039#discussion_r1994461145


##
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.java:
##
@@ -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.
+ */
[email protected](
+name = "compact",
+description = "CLI to compact a column-family in the DB. while the service 
is offline. \n" +

Review Comment:
   nit. punctuation typo.
   ```suggestion
   description = "CLI to compact a column-family in the DB while the 
service is offline.\n" +
   ```



##
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.java:
##
@@ -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.
+ */
[email protected](
+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 cfHandleList = new ArrayList<>();
+List 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 +

Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-13 Thread via GitHub


errose28 commented on code in PR #8039:
URL: https://github.com/apache/ozone/pull/8039#discussion_r1992425023


##
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.java:
##
@@ -0,0 +1,85 @@
+/*
+ * 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.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+import picocli.CommandLine;
+
+/**
+ * Tool to perform compaction on a table.
+ */
[email protected](
+name = "compact",
+description = "CLI to compact a column-family in the DB. " +
+"Note: If om.db is compacted then it will impact 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"},

Review Comment:
   This order means that if the flag is omitted, the kebab case version is the 
first suggestion, which is more standard.
   ```suggestion
 @CommandLine.Option(names = {"--column-family", "--column_family", "--cf"},
   ```



##
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.java:
##
@@ -0,0 +1,85 @@
+/*
+ * 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.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+import picocli.CommandLine;
+
+/**
+ * Tool to perform compaction on a table.
+ */
[email protected](
+name = "compact",
+description = "CLI to compact a column-family in the DB. " +
+"Note: If om.db is compacted then it will impact 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 cfHandleList = new ArrayList<>();
+List cfDescList = 
RocksDBU

Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-13 Thread via GitHub


Tejaskriya commented on PR #8039:
URL: https://github.com/apache/ozone/pull/8039#issuecomment-2721624599

   Thanks for the reviews @jojochuang @errose28. I have made the improvements 
as suggested!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-13 Thread via GitHub


Tejaskriya commented on code in PR #8039:
URL: https://github.com/apache/ozone/pull/8039#discussion_r1993680065


##
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.java:
##
@@ -0,0 +1,85 @@
+/*
+ * 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.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+import picocli.CommandLine;
+
+/**
+ * Tool to perform compaction on a table.
+ */
[email protected](
+name = "compact",
+description = "CLI to compact a column-family in the DB. " +
+"Note: If om.db is compacted then it will impact 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 cfHandleList = new ArrayList<>();
+List 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);
+  if (!isDryRun()) {
+ManagedCompactRangeOptions compactOptions = new 
ManagedCompactRangeOptions();
+
compactOptions.setBottommostLevelCompaction(ManagedCompactRangeOptions.BottommostLevelCompaction.kForce);
+db.get().compactRange(cfh, null, null, compactOptions);
+  }
+  info("Compaction completed.");
+
+} catch (RocksDBException exception) {
+  error("Failed to compact the RocksDB for the given path: %s, 
column-family:%s", dbPath, columnFamilyName);
+  error("Exception: " + exception);

Review Comment:
   Updated the error messages now, it prints like this now:
   ```
   bash-4.2$ ozone repair ldb  compact --db=/data/metadata/om.db --cf=fileTable
   ATTENTION: Running as user hadoop. Make sure this is the same user used to 
run the Ozone process. Are you sure you want to continue (y/N)? y
   Run as user: hadoop
   Exception: org.rocksdb.RocksDBException: While lock file: 
/data/metadata/om.db/LOCK: Resource temporarily unavailable
   Failed to compact RocksDB for the given path: /data/metadata/om.db, 
column-family:fileTable
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HDDS-12533. Offline repair command for generic rocksDB compaction [ozone]

2025-03-12 Thread via GitHub


errose28 commented on code in PR #8039:
URL: https://github.com/apache/ozone/pull/8039#discussion_r1992433976


##
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/ldb/RocksDBManualCompaction.java:
##
@@ -0,0 +1,85 @@
+/*
+ * 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.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDBException;
+import picocli.CommandLine;
+
+/**
+ * Tool to perform compaction on a table.
+ */
[email protected](
+name = "compact",
+description = "CLI to compact a column-family in the DB. " +
+"Note: If om.db is compacted then it will impact 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"},

Review Comment:
   For example, the current version prints:
   ```
   $ ./ozone repair ldb compact --db=lkjhlk
   Missing required option: '--column_family='
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]