You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fluss.apache.org by yu...@apache.org on 2025/09/18 12:40:03 UTC

(fluss) branch main updated: [server] Updated Default RocksDB Log Directory to a separate directory (#1675)

This is an automated email from the ASF dual-hosted git repository.

yuxia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluss.git


The following commit(s) were added to refs/heads/main by this push:
     new a8cef413c [server] Updated Default RocksDB Log Directory to a separate directory (#1675)
a8cef413c is described below

commit a8cef413c044c789b001ac62592471ffd08cdf10
Author: Rion Williams <ri...@gmail.com>
AuthorDate: Thu Sep 18 07:39:58 2025 -0500

    [server] Updated Default RocksDB Log Directory to a separate directory (#1675)
---
 .../fluss/server/kv/rocksdb/RocksDBResourceContainer.java | 15 +++++++++++----
 .../server/kv/rocksdb/RocksDBResourceContainerTest.java   |  4 +++-
 website/docs/maintenance/configuration.md                 |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/fluss-server/src/main/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainer.java b/fluss-server/src/main/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainer.java
index 707c45a28..d437c0878 100644
--- a/fluss-server/src/main/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainer.java
+++ b/fluss-server/src/main/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainer.java
@@ -22,6 +22,7 @@ import org.apache.fluss.config.ConfigOption;
 import org.apache.fluss.config.ConfigOptions;
 import org.apache.fluss.config.Configuration;
 import org.apache.fluss.config.ReadableConfig;
+import org.apache.fluss.utils.FileUtils;
 import org.apache.fluss.utils.IOUtils;
 
 import org.rocksdb.BlockBasedTableConfig;
@@ -42,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import javax.annotation.Nullable;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -99,7 +101,7 @@ public class RocksDBResourceContainer implements AutoCloseable {
     }
 
     /** Gets the RocksDB {@link DBOptions} to be used for RocksDB instances. */
-    public DBOptions getDbOptions() {
+    public DBOptions getDbOptions() throws IOException {
         // initial options from common profile
         DBOptions opt = createBaseCommonDBOptions();
         handlesToClose.add(opt);
@@ -175,7 +177,8 @@ public class RocksDBResourceContainer implements AutoCloseable {
     }
 
     @SuppressWarnings("ConstantConditions")
-    private DBOptions setDBOptionsFromConfigurableOptions(DBOptions currentOptions) {
+    private DBOptions setDBOptionsFromConfigurableOptions(DBOptions currentOptions)
+            throws IOException {
         currentOptions.setMaxBackgroundJobs(
                 internalGetOption(ConfigOptions.KV_MAX_BACKGROUND_THREADS));
 
@@ -280,12 +283,16 @@ public class RocksDBResourceContainer implements AutoCloseable {
      *
      * @param dbOptions The RocksDB {@link DBOptions}.
      */
-    private void relocateDefaultDbLogDir(DBOptions dbOptions) {
+    private void relocateDefaultDbLogDir(DBOptions dbOptions) throws IOException {
         String logFilePath = System.getProperty("log.file");
         if (logFilePath != null) {
             File logFile = resolveFileLocation(logFilePath);
             if (logFile != null && resolveFileLocation(logFile.getParent()) != null) {
-                dbOptions.setDbLogDir(logFile.getParent());
+                File logFileDirectory = logFile.getParentFile();
+                File rocksDbLogDirectory = FileUtils.createDirectory(logFileDirectory, "rocksdb");
+                if (resolveFileLocation(rocksDbLogDirectory.getAbsolutePath()) != null) {
+                    dbOptions.setDbLogDir(rocksDbLogDirectory.getAbsolutePath());
+                }
             }
         }
     }
diff --git a/fluss-server/src/test/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainerTest.java b/fluss-server/src/test/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainerTest.java
index 005483528..f36853cd4 100644
--- a/fluss-server/src/test/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainerTest.java
+++ b/fluss-server/src/test/java/org/apache/fluss/server/kv/rocksdb/RocksDBResourceContainerTest.java
@@ -108,7 +108,9 @@ class RocksDBResourceContainerTest {
         System.setProperty("log.file", logFile.getPath());
         try (RocksDBResourceContainer container = new RocksDBResourceContainer()) {
             assertThat(container.getDbOptions().infoLogLevel()).isEqualTo(InfoLogLevel.INFO_LEVEL);
-            assertThat(container.getDbOptions().dbLogDir()).isEqualTo(logFile.getParent());
+            File rocksDbLogDirectory = new File(logFile.getParent(), "rocksdb");
+            assertThat(container.getDbOptions().dbLogDir())
+                    .isEqualTo(rocksDbLogDirectory.getAbsolutePath());
         } finally {
             logFile.delete();
         }
diff --git a/website/docs/maintenance/configuration.md b/website/docs/maintenance/configuration.md
index 79ca3c347..d2fad94a1 100644
--- a/website/docs/maintenance/configuration.md
+++ b/website/docs/maintenance/configuration.md
@@ -136,7 +136,7 @@ during the Fluss cluster working.
 | kv.rocksdb.files.open                             | Integer    | -1                            | The maximum number of open files (per  bucket of table) that can be used by the DB, `-1` means no limit. The default value is `-1`.                                                                                                                                                                                                                                                                       [...]
 | kv.rocksdb.log.max-file-size                      | MemorySize | 25mb                          | The maximum size of RocksDB's file used for information logging. If the log files becomes larger than this, a new file will be created. If 0, all logs will be written to one log file. The default maximum file size is `25MB`.                                                                                                                                                                          [...]
 | kv.rocksdb.log.file-num                           | Integer    | 4                             | The maximum number of files RocksDB should keep for information logging (Default setting: 4).                                                                                                                                                                                                                                                                                                             [...]
-| kv.rocksdb.log.dir                                | String     | (None)                        | The directory for RocksDB's information logging files. If empty (Fluss default setting), log files will be in the same directory as the Fluss log. If non-empty, this directory will be used and the data directory's absolute path will be used as the prefix of the log file name. If setting this option as a non-existing location, e.g `/dev/null`, RocksDB will then create the log under its own d [...]
+| kv.rocksdb.log.dir                                | String     | `${FLUSS_HOME}/log/rocksdb`               | The directory for RocksDB's information logging files. If empty (Fluss default setting), log files will be in the same directory as the Fluss log. If non-empty, this directory will be used and the data directory's absolute path will be used as the prefix of the log file name. If setting this option as a non-existing location, e.g `/dev/null`, RocksDB will then create the log und [...]
 | kv.rocksdb.log.level                              | Enum       | INFO_LEVEL                    | The specified information logging level for RocksDB. Candidate log level is `DEBUG_LEVEL`, `INFO_LEVEL`, `WARN_LEVEL`, `ERROR_LEVEL`, `FATAL_LEVEL`, `HEADER_LEVEL`, NUM_INFO_LOG_LEVELS, . If unset, Fluss will use INFO_LEVEL. Note: RocksDB info logs will not be written to the Fluss's tablet server logs and there is no rolling strategy, unless you configure `kv.rocksdb.log.dir`, `kv.rocksdb.l [...]
 | kv.rocksdb.write-batch-size                       | MemorySize | 2mb                           | The max size of the consumed memory for RocksDB batch write, will flush just based on item count if this config set to 0.                                                                                                                                                                                                                                                                                 [...]
 | kv.rocksdb.compaction.style                       | Enum       | LEVEL                         | The specified compaction style for DB. Candidate compaction style is LEVEL, FIFO, UNIVERSAL, or NONE, and Fluss chooses `LEVEL` as default style.                                                                                                                                                                                                                                                         [...]