Skip to content

nlog: add disk-pressure-aware retention to fix #721#1139

Open
SBALAVIGNESH123 wants to merge 1 commit intotimeplus-io:developfrom
SBALAVIGNESH123:fix/nlog-disk-pressure-retention
Open

nlog: add disk-pressure-aware retention to fix #721#1139
SBALAVIGNESH123 wants to merge 1 commit intotimeplus-io:developfrom
SBALAVIGNESH123:fix/nlog-disk-pressure-retention

Conversation

@SBALAVIGNESH123
Copy link
Copy Markdown
Contributor

Fixes #721

When disk usage reaches 90%, the existing retention policy doesn't kick in because the min_size_to_keep guard (default 4GB) blocks deletion — even if the disk is nearly full, individual logs smaller than 4GB won't have their segments cleaned up. This means retention only works based on per-log size and time thresholds, but never considers actual disk space.

This PR adds a fourth deletion strategy, deleteDiskPressureBreachedSegments, that activates only when disk usage exceeds a configurable threshold (default 90%). When triggered, it bypasses the min_size_to_keep guard and deletes the oldest segments to free disk space. The active segment is always preserved by the existing deletableSegments() mechanism. When disk usage is below the threshold, behavior is completely unchanged.

Changes:

  • LogConfig.h / LogConfig.cpp — Added disk_usage_threshold_percent (default 90%) with validation and debug output
  • Log.h / Log.cpp — Added deleteDiskPressureBreachedSegments() as a fourth deletion strategy, called only when disk_pressure flag is true
  • LogManager.cpp — Added std::filesystem::space() check on each root directory in cleanupLogs() to detect disk pressure

@SBALAVIGNESH123 SBALAVIGNESH123 force-pushed the fix/nlog-disk-pressure-retention branch from 0f6e526 to ab382cb Compare March 20, 2026 13:55
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.

Retention policy didn't kick in for nativelog when disk usage reaches 90%

1 participant