Skip to content

fix log dir#371

Merged
lokax merged 2 commits into
mainfrom
yf-glog
Dec 17, 2025
Merged

fix log dir#371
lokax merged 2 commits into
mainfrom
yf-glog

Conversation

@lokax

@lokax lokax commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Initialized and integrated enhanced Google-based logging to improve startup logging and error reporting.
    • Updated an internal data substrate submodule pointer (no functional behavior changes).

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 16, 2025 07:18
@coderabbitai

coderabbitai Bot commented Dec 16, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds Google Logging initialization and header inclusion in EloqKVEngine and updates the eloq data_substrate submodule pointer; no changes to exported declarations.

Changes

Cohort / File(s) Summary
Google Logging integration
src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp
Added glog_error_logging.h include; in EloqKVEngine constructor derive log directory from serverGlobalParams.logpath, set log_dir GFLAGS when available, and call InitGoogleLogging with a dummy argv before DataSubstrate init.
Submodule pointer update
src/mongo/db/modules/eloq/data_substrate/...
Updated submodule commit pointer from 0c6d867... to 00f6405...; no functional code changes noted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Areas to check:
    • Correctness and safety of serverGlobalParams.logpath parsing.
    • Interaction/timing with DataSubstrate initialization and any global log shutdown semantics.

Possibly related PRs

Suggested labels

trigger-ci

Suggested reviewers

  • lzxddz
  • xiexiaoy

Poem

🐰 A little rabbit pads through code at night,
Places glog flags and sets the logpath right,
A quick InitGoogleLogging, no fuss in sight,
Submodule nudged, then off in moonlight—
Hop-hop, the build will soon take flight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'fix log dir' is vague and generic, using non-descriptive terms that don't clearly convey the specific change being made. Consider a more descriptive title that explains the specific fix, such as 'Integrate Google Logging with server log directory configuration' or 'Initialize Google Logging with serverGlobalParams.logpath'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4edb1c and 1a9d1c7.

📒 Files selected for processing (2)
  • src/mongo/db/modules/eloq/data_substrate (1 hunks)
  • src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lokax lokax linked an issue Dec 16, 2025 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the log directory configuration for the Eloq storage engine by properly initializing Google logging with the system's configured log path. The changes ensure that glog writes to the correct directory based on MongoDB's server configuration.

Key Changes:

  • Added initialization of Google logging (glog) with proper log directory configuration extracted from MongoDB's server global parameters
  • Updated the data_substrate submodule to a newer version
  • Reformatted Python code in SConscript for improved readability and style consistency

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp Added glog initialization with log directory configuration from server parameters
src/mongo/db/modules/eloq/data_substrate Updated submodule commit reference
src/mongo/db/modules/eloq/SConscript Applied Python code formatting improvements and added jemalloc support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


std::filesystem::path systemLogPath(serverGlobalParams.logpath);
if (systemLogPath.has_parent_path()) {
static std::filesystem::path logdir = systemLogPath.parent_path();

Copilot AI Dec 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable is declared as static, which means it will persist across multiple constructor invocations. If the EloqKVEngine constructor is called multiple times with different paths, the logdir will retain the value from the first invocation and ignore subsequent changes to serverGlobalParams.logpath. Consider removing the static keyword unless there's a specific reason to persist this value across instances.

Suggested change
static std::filesystem::path logdir = systemLogPath.parent_path();
std::filesystem::path logdir = systemLogPath.parent_path();

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +161
char** dummy_argv = const_cast<char**>(tmp);
InitGoogleLogging(dummy_argv);

Copilot AI Dec 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function InitGoogleLogging typically expects a single char* argument (the program name), but this code passes char**. Verify that this is the correct API signature for the version of glog being used. Most glog versions use InitGoogleLogging(const char* argv0) which would only require InitGoogleLogging("eloqdb").

Suggested change
char** dummy_argv = const_cast<char**>(tmp);
InitGoogleLogging(dummy_argv);
// char** dummy_argv = const_cast<char**>(tmp);
InitGoogleLogging(tmp[0]);

Copilot uses AI. Check for mistakes.
Comment thread src/mongo/db/modules/eloq/SConscript Outdated
if jemalloc_lib is None:
print("ERROR: WITH_JEMALLOC=ON but libjemalloc not found")
Exit(1)
jemalloc_deps = []

Copilot AI Dec 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable jemalloc_deps is initialized to an empty list twice: once before the conditional block at line 143 and again inside the conditional block at line 150. Remove the redundant initialization at line 150.

Suggested change
jemalloc_deps = []

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/mongo/db/modules/eloq/SConscript (1)

122-138: Bug: LOG_STATE_TYPE_RKDB_MEMORY is undefined.

Line 124 references LOG_STATE_TYPE_RKDB_MEMORY, but only LOG_STATE_TYPE_MEM is defined at line 66. This will cause a NameError at runtime when WITH_LOG_STATE=MEMORY is set.

 if with_log_state_str == "MEMORY":
-    with_log_state = LOG_STATE_TYPE_RKDB_MEMORY
+    with_log_state = LOG_STATE_TYPE_MEM
     env.Append(CPPDEFINES=["LOG_STATE_TYPE_MEM"])
🧹 Nitpick comments (4)
src/mongo/db/modules/eloq/SConscript (4)

143-151: Redundant re-initialization of jemalloc_deps.

Line 150 re-initializes jemalloc_deps = [] immediately before appending, but it was already initialized at line 143. This is harmless but redundant.

 jemalloc_deps = []
 if os.environ.get("WITH_JEMALLOC", "0") in ("1", "ON", "on", "true", "True"):
     env.Append(CPPDEFINES=["WITH_JEMALLOC"])
     jemalloc_lib = FindLibPath("jemalloc")
     if jemalloc_lib is None:
         print("ERROR: WITH_JEMALLOC=ON but libjemalloc not found")
         Exit(1)
-    jemalloc_deps = []
     jemalloc_deps.append(jemalloc_lib)

44-44: Consider removing debug print statement.

This debug print will produce output for every candidate path checked during the build, which could be noisy. Consider removing or making it conditional on a verbose flag.

-                print("candidate:", candidate)

171-199: Potential duplicate include paths.

The include paths for rocksdb_cloud_header, aws/*, and google/cloud/storage are added unconditionally at lines 171-178 and then conditionally added again at lines 184-199. While SCons may deduplicate these, it's cleaner to add them only once. Consider removing the unconditional additions at lines 172-178 since they're properly handled conditionally below.

Additionally, lines 171-178 don't filter out None values from FindIncludePath, which could add None to CPPPATH.


305-327: Duplicate library entries in GCS log state branch.

Lines 306-307 add google_cloud_cpp_common, google_cloud_cpp_storage, and rocksdb-cloud-gcp, then lines 308-312 add them again within the same conditional block. This duplication is likely unintentional.

 elif with_log_state == LOG_STATE_TYPE_RKDB_GCS:
     env.Append(LIBS=["google_cloud_cpp_common"])
     env.Append(LIBS=["google_cloud_cpp_storage", "rocksdb-cloud-gcp"])
     env.Append(LIBS=[
-        "google_cloud_cpp_common",
-        "google_cloud_cpp_storage",
-        "rocksdb-cloud-gcp",
         "rocksdb",
         "absl_base",
         ...
     ])
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83690ed and d08b239.

📒 Files selected for processing (3)
  • src/mongo/db/modules/eloq/SConscript (13 hunks)
  • src/mongo/db/modules/eloq/data_substrate (1 hunks)
  • src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp (2 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 211
File: src/mongo/db/modules/eloq/cmake/build_eloq_log_service.cmake:26-80
Timestamp: 2025-09-25T12:24:06.434Z
Learning: The user githubzilla implemented a fix in commit fe98aaf to address the MEMORY state incorrectly triggering RocksDB discovery in build_eloq_log_service.cmake. This was a control flow issue where MEMORY builds were falling into an else branch that still attempted RocksDB discovery.
Learnt from: lzxddz
Repo: eloqdata/eloqdoc PR: 325
File: src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp:1362-1384
Timestamp: 2025-11-24T03:11:24.955Z
Learning: The EloqDoc codebase uses an older version of glog that supports the two-parameter signature `google::InitGoogleLogging(const char* argv0, PrefixCallback)` for custom log prefix formatting, as seen in src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp line 1383.
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 279
File: src/mongo/db/modules/eloq/CMakeLists.txt:54-55
Timestamp: 2025-11-28T10:55:21.020Z
Learning: In src/mongo/db/modules/eloq/CMakeLists.txt, the CMake options EXT_TX_PROC_ENABLED, FORK_HM_PROCESS, and STATISTICS are used by the data_substrate submodule build system and should be retained as configuration interface options.
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 211
File: src/mongo/db/modules/eloq/cmake/build_log_service.cmake:116-119
Timestamp: 2025-09-25T11:58:50.446Z
Learning: The build_log_service.cmake file is specifically for "open log" functionality and only supports the ROCKSDB log state type (LOG_STATE_TYPE_RKDB). The full log state configuration with cloud variants (ROCKSDB_CLOUD_S3, ROCKSDB_CLOUD_GCS) is handled in build_eloq_log_service.cmake.
📚 Learning: 2025-11-28T10:55:21.020Z
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 279
File: src/mongo/db/modules/eloq/CMakeLists.txt:54-55
Timestamp: 2025-11-28T10:55:21.020Z
Learning: In src/mongo/db/modules/eloq/CMakeLists.txt, the CMake options EXT_TX_PROC_ENABLED, FORK_HM_PROCESS, and STATISTICS are used by the data_substrate submodule build system and should be retained as configuration interface options.

Applied to files:

  • src/mongo/db/modules/eloq/data_substrate
  • src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp
  • src/mongo/db/modules/eloq/SConscript
📚 Learning: 2025-11-24T03:11:24.955Z
Learnt from: lzxddz
Repo: eloqdata/eloqdoc PR: 325
File: src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp:1362-1384
Timestamp: 2025-11-24T03:11:24.955Z
Learning: The EloqDoc codebase uses an older version of glog that supports the two-parameter signature `google::InitGoogleLogging(const char* argv0, PrefixCallback)` for custom log prefix formatting, as seen in src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp line 1383.

Applied to files:

  • src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp
📚 Learning: 2025-09-25T11:58:50.446Z
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 211
File: src/mongo/db/modules/eloq/cmake/build_log_service.cmake:116-119
Timestamp: 2025-09-25T11:58:50.446Z
Learning: The build_log_service.cmake file is specifically for "open log" functionality and only supports the ROCKSDB log state type (LOG_STATE_TYPE_RKDB). The full log state configuration with cloud variants (ROCKSDB_CLOUD_S3, ROCKSDB_CLOUD_GCS) is handled in build_eloq_log_service.cmake.

Applied to files:

  • src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp
  • src/mongo/db/modules/eloq/SConscript
📚 Learning: 2025-09-25T12:09:01.276Z
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 211
File: src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp:95-115
Timestamp: 2025-09-25T12:09:01.276Z
Learning: The log states (LOG_STATE_TYPE_RKDB, LOG_STATE_TYPE_RKDB_S3, LOG_STATE_TYPE_RKDB_GCS) in the EloqDoc codebase are mutually exclusive - only one can be active at a time. The LOG_STATE_TYPE_RKDB_CLOUD macro is a helper that should only be defined for cloud variants (S3/GCS) and not when regular RKDB is active.

Applied to files:

  • src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp
  • src/mongo/db/modules/eloq/SConscript
📚 Learning: 2025-11-28T10:52:25.527Z
Learnt from: githubzilla
Repo: eloqdata/eloqdoc PR: 279
File: concourse/scripts/main.ent.bash:38-39
Timestamp: 2025-11-28T10:52:25.527Z
Learning: In the eloqdoc enterprise build (main.ent.bash), eloq_log_service is fetched separately as the resource `eloq_logservice_src` in the pipeline (main.ent.yml) and then symlinked into the data_substrate directory structure at build time using `ln -s $WORKSPACE/eloq_logservice_src eloq_log_service`. This is the intended architecture for placing eloq_log_service within data_substrate in the enterprise configuration.

Applied to files:

  • src/mongo/db/modules/eloq/SConscript
🪛 Cppcheck (2.18.0)
src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp

[error] 161-161: #error "Unsupported compiler family"

(preprocessorErrorDirective)

🪛 GitHub Actions: Copilot code review
src/mongo/db/modules/eloq/data_substrate

[error] 1-1: autofind failed: Error getting common flags: diff references file 'src/mongo/db/modules/eloq/data_substrate' that is not present in repo (likely incorrect repo root).

🔇 Additional comments (3)
src/mongo/db/modules/eloq/data_substrate (1)

1-1: Verify the submodule commit aligns with PR objectives.

This is a submodule update to data_substrate. Without visibility into what changed in the submodule, please verify that the new commit (834641d...) relates to the PR objective ("fix log dir") and does not introduce breaking changes or require additional coordination with the related Google Logging initialization and build configuration changes mentioned in the summary.

To help verify this, please provide:

  • A summary of what changed in the data_substrate submodule between the old and new commits
  • Confirmation that the update is compatible with the Google Logging initialization changes to eloq_kv_engine and the build configuration refinements mentioned in the PR summary
src/mongo/db/modules/eloq/src/eloq_kv_engine.cpp (2)

38-38: LGTM!

The include for glog_error_logging.h is correctly added to support the new Google Logging initialization.


153-162: Glog initialization is safe in this codebase despite the general concern.

glog does not support multiple calls to InitGoogleLogging and will produce a fatal error if called twice. However, the proposed guard is unnecessary here because EloqKVEngine is instantiated exactly once in the factory pattern (eloq_init.cpp:48 via make_unique), and the class has deleted copy/move constructors preventing accidental duplication.

The real concern is the secondary issue: add a default or warning when serverGlobalParams.logpath has no parent directory, as log_dir will silently remain unset in that case.

@lokax lokax removed the trigger-ci label Dec 17, 2025
@lokax lokax merged commit fda3b2a into main Dec 17, 2025
2 checks passed
@lokax lokax deleted the yf-glog branch December 17, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: eloqdoc glog cannot be dumped to log file

3 participants