Skip to content

[bugfix] Fix GetInfoLogFiles using wrong path for log file prefix - #8

Merged
patpatbear merged 1 commit into
ctrip-v8.5.4from
hotfix/rocksdb_getinfolog_files
Apr 30, 2026
Merged

[bugfix] Fix GetInfoLogFiles using wrong path for log file prefix#8
patpatbear merged 1 commit into
ctrip-v8.5.4from
hotfix/rocksdb_getinfolog_files

Conversation

@qiongtubao

Copy link
Copy Markdown

When db_log_dir is set and dbname is a relative path, GetInfoLogFiles incorrectly uses dbname instead of db_absolute_path to build the log file prefix. This causes mismatch with InfoLogFileName which uses db_absolute_path, resulting in failure to identify existing log files during AutoRollLogger restart. Consequently, log files accumulate beyond the keep_log_file_num limit.

Root cause: GetInfoLogFiles used dbname for InfoLogPrefix construction while InfoLogFileName uses db_absolute_path. When these differ (e.g., relative dbname vs absolute cwd), the prefixes don't match.

Fix: Add db_absolute_path parameter to GetInfoLogFiles and use it for InfoLogPrefix construction, consistent with InfoLogFileName behavior.

Changes:

  • file/filename.h: Add db_absolute_path parameter
  • file/filename.cc: Use db_absolute_path for InfoLogPrefix
  • logging/auto_roll_logger.cc: Pass db_absolute_path_ to GetInfoLogFiles
  • utilities/convenience/info_log_finder.cc: Get and pass db_absolute_path
  • logging/auto_roll_logger_test.cc: Add test case GetInfoLogFilesPrefixMismatch

When db_log_dir is set and dbname is a relative path, GetInfoLogFiles
incorrectly uses dbname instead of db_absolute_path to build the log
file prefix. This causes mismatch with InfoLogFileName which uses
db_absolute_path, resulting in failure to identify existing log files
during AutoRollLogger restart. Consequently, log files accumulate
beyond the keep_log_file_num limit.

Root cause: GetInfoLogFiles used dbname for InfoLogPrefix construction
while InfoLogFileName uses db_absolute_path. When these differ (e.g.,
relative dbname vs absolute cwd), the prefixes don't match.

Fix: Add db_absolute_path parameter to GetInfoLogFiles and use it for
InfoLogPrefix construction, consistent with InfoLogFileName behavior.

Changes:
- file/filename.h: Add db_absolute_path parameter
- file/filename.cc: Use db_absolute_path for InfoLogPrefix
- logging/auto_roll_logger.cc: Pass db_absolute_path_ to GetInfoLogFiles
- utilities/convenience/info_log_finder.cc: Get and pass db_absolute_path
- logging/auto_roll_logger_test.cc: Add test case GetInfoLogFilesPrefixMismatch
@patpatbear
patpatbear merged commit f00669c into ctrip-v8.5.4 Apr 30, 2026
0 of 2 checks passed
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.

2 participants