Skip to content

feat: Add configuration flag --log-retention-days#3862

Merged
as51340 merged 3 commits intomasterfrom
feat/add-log-retention-config
Mar 5, 2026
Merged

feat: Add configuration flag --log-retention-days#3862
as51340 merged 3 commits intomasterfrom
feat/add-log-retention-config

Conversation

@as51340
Copy link
Copy Markdown
Contributor

@as51340 as51340 commented Mar 4, 2026

What

Introduces a new --log-retention-days configuration flag that controls how many days daily log files are preserved. The previously hard-coded retention count of 35 is now a
user-configurable gflags parameter with a validated range of 1–max(uint16_t)

Why

Log retention was hard-coded to 35 days with no way to adjust it at runtime or deployment time. Users running Memgraph in environments with stricter storage constraints or
compliance requirements had no control over how long log files were kept.

How

  • Replaced the inline constexpr auto log_retention_count = 35 constant in src/flags/logging.cpp with a DEFINE_VALIDATED_uint64(log_retention_days, ...) flag
  • The daily_file_sink_st constructor call now uses FLAGS_log_retention_days instead of the old constant.
  • Minor reformatting of the DEFINE_VALIDATED_string for logger_type (namespace qualification of utils::ToLowerCasememgraph::utils::ToLowerCase since the flag
    definition sits outside namespace memgraph::flags).

Testing

  • Updated tests/e2e/configuration/default_config.py to include log_retention_days with its expected default value ("35"), ensuring the default-config e2e test validates the
    new flag.
  • No new unit tests added — the flag uses DEFINE_VALIDATED_uint64 with FLAG_IN_RANGE, which is a well-tested gflags validation macro, and the downstream behaviour (spdlog
    daily sink retention) is third-party code.

@as51340 as51340 added this to the mg-v3.8.2 milestone Mar 4, 2026
@as51340 as51340 requested a review from andrejtonev March 4, 2026 14:36
@as51340 as51340 self-assigned this Mar 4, 2026
@as51340 as51340 added feature feature Docs - changelog only Docs - changelog only CI -build=coverage -test=core Run coverage build and core tests on push CI -build=jepsen -test=core Run jepsen build and core tests on push CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push CI -build=coverage -test=clang_tidy Docs needed Docs needed and removed Docs - changelog only Docs - changelog only labels Mar 4, 2026
@as51340
Copy link
Copy Markdown
Contributor Author

as51340 commented Mar 4, 2026

Tracking

  • [Link to Epic/Issue]

Standard development

CI Testing Labels

  • Select the appropriate CI test labels (CI -build=build-name -test=test-suite)

Documentation checklist

  • Add the documentation label
  • Add the bug / feature label
  • Add the milestone for which this feature is intended
    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    • Memgraph now exposes a --log-retention-days configuration flag that controls how many days daily log files are kept before being automatically removed; the default remains 35
      days (5 weeks), matching the previous hard-coded behavior, so no action is needed unless you want to customize retention by setting the flag to a value larger than one.
      #3862
    • What has changed? What does it mean for a user? What should a user do with it? [#{{PR_number}}]({{link to the PR}})
  • Documentation PR link memgraph/documentation#XXXX
    • Is back linked to this development PR

@as51340 as51340 enabled auto-merge March 5, 2026 08:11
@as51340 as51340 added this pull request to the merge queue Mar 5, 2026
github-merge-queue bot pushed a commit that referenced this pull request Mar 5, 2026
## What

Introduces a new `--log-retention-days` configuration flag that controls
how many days daily log files are preserved. The previously hard-coded
retention count of 35 is now a
user-configurable `gflags` parameter with a validated range of
1–max(uint16_t)

## Why

Log retention was hard-coded to 35 days with no way to adjust it at
runtime or deployment time. Users running Memgraph in environments with
stricter storage constraints or
compliance requirements had no control over how long log files were
kept.

## How

- Replaced the `inline constexpr auto log_retention_count = 35` constant
in `src/flags/logging.cpp` with a
`DEFINE_VALIDATED_uint64(log_retention_days, ...)` flag
- The `daily_file_sink_st` constructor call now uses
`FLAGS_log_retention_days` instead of the old constant.
- Minor reformatting of the `DEFINE_VALIDATED_string` for `logger_type`
(namespace qualification of `utils::ToLowerCase` →
`memgraph::utils::ToLowerCase` since the flag
definition sits outside `namespace memgraph::flags`).

## Testing

- Updated `tests/e2e/configuration/default_config.py` to include
`log_retention_days` with its expected default value (`"35"`), ensuring
the default-config e2e test validates the
 new flag.
- No new unit tests added — the flag uses `DEFINE_VALIDATED_uint64` with
`FLAG_IN_RANGE`, which is a well-tested gflags validation macro, and the
downstream behaviour (spdlog
daily sink retention) is third-party code.
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 5, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 5, 2026

@as51340 as51340 added this pull request to the merge queue Mar 5, 2026
Merged via the queue into master with commit 4fa8d25 Mar 5, 2026
40 checks passed
@as51340 as51340 deleted the feat/add-log-retention-config branch March 5, 2026 10:43
@mattkjames7 mattkjames7 removed this from the mg-v3.8.2 milestone Mar 9, 2026
@mattkjames7 mattkjames7 added this to the mg-v3.9.0 milestone Mar 9, 2026
@gitbuda gitbuda mentioned this pull request Mar 11, 2026
68 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI -build=coverage -test=clang_tidy CI -build=coverage -test=core Run coverage build and core tests on push CI -build=jepsen -test=core Run jepsen build and core tests on push CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push Docs needed Docs needed feature feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants