Project

General

Profile

Actions

Feature #75467

closed
DV LS

warn and revert if a daemon has excessively high debug levels for a long time

Feature #75467: warn and revert if a daemon has excessively high debug levels for a long time

Added by Dan van der Ster 9 months ago. Updated 2 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
Reviewed:
Affected Versions:
Component(RADOS):
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-3872-gd0a1e79d27
Released In:
Upkeep Timestamp:
2026-09-30T22:48:14+00:00

Description

debug_* above 5 is expensive -- in extreme cases debug_* > 20 has been known to cause significant service outages.

this tracker is to propose a new warn/revert feature for all ceph daemons.

I propose these new global config options:

  • "high_debug_level_threshold" (default 5): the log level we consider to be high.
  • "warn_on_high_debug_levels" (default true): a health warning will be issued by a daemon if it has a debug level above the threshold.
  • "high_debug_level_reset_timeout" (default 60): a debug setting will be reverted to the default if it has been enabled for this many seconds. 0 means unlimited.
  • "high_debug_level_reset_max_lines" (default 1000): a debug setting will be reverted to the default if it has printed this many lines. 0 means unlimited.

For the implementation, it might be best/easiest to just hook into dout itself, and decide if we need to warn/revert while doing the dout.
First, it's sensible to only warn/revert if the debug option is actually used by a daemon -- "high" debug settings on prefixes that a daemon never uses are harmless anyway.
Similarly, regarding the timeout, we only care if the dout is being super verbose -- so we need to count the number of times we were called, and also how long it's been since the first time this dout level was called. Once we exceed the thresholds, we revert.

Changing a debug_ level should reset all warnings/timeouts/counts -- this may be difficult because daemons don't learn about debug levels until it tries to dout.

DV Updated by Dan van der Ster 9 months ago Actions #1

Gemini Pro suggested a better implementation strategy:

Feature Proposal: Auto-revert and Health Warnings for High Debug Levels

Motivation

Running Ceph daemons with high debug levels (e.g., debug_* above 5) is computationally expensive and generates massive disk I/O. In extreme cases, leaving debug levels set too high (e.g., > 20) for too long is a known cause of significant service outages and full disks.

This tracker proposes a new self-healing warn/revert feature for all Ceph daemons to automatically protect the cluster from "forgotten" debug configurations.

Proposed Configuration Options

I propose adding the following global configuration options:

  • high_debug_level_threshold (default: 5): The log level threshold we consider to be "high" and potentially dangerous if left unchecked.
  • warn_on_high_debug_levels (default: true): If a daemon has a debug level at or above the threshold, it will issue a cluster health warning.
  • high_debug_level_reset_timeout (default: 300): If a debug setting remains at or above the threshold for this many seconds (5 minutes), it will automatically revert to its default value. 0 means unlimited.
  • high_debug_level_reset_max_lines (default: 100000): If a debug setting at or above the threshold prints this many lines, it will automatically revert to the default. 0 means unlimited.

Proposed Implementation Strategy

Handling the Timeout (Config Observers):

Instead of checking timeouts on every log emission (which would add overhead to the dout hot-path), we should leverage the configuration observer framework (md_config_obs_t). When a debug level is changed via the admin socket or monitor, the observer callback will trigger. If the new level exceeds the high_debug_level_threshold, we spawn an async timer thread. If the timer expires before the config is changed again, the daemon resets the config to default.

Handling the Line Limit (dout Hook):

To track high_debug_level_reset_max_lines, we will need to hook into dout. Because dout is incredibly heavily utilized, we must protect its performance. We can use a fast atomic counter to track the lines emitted for that specific subsystem. Once the threshold is breached, the subsystem's debug level is reverted, and the counter is reset.

Resetting the Counters:

Any time an admin explicitly changes a debug_ level, the configuration observer will immediately reset all associated timeouts, line counters, and warnings for that subsystem, giving the admin a fresh window.

RZ Updated by Radoslaw Zarzynski 9 months ago Actions #2

Handling the Line Limit (dout Hook):

To track high_debug_level_reset_max_lines, we will need to hook into dout. Because dout is incredibly heavily utilized, we must protect its performance. We can use a fast atomic counter to track the > lines emitted for that specific subsystem. Once the threshold is breached, the subsystem's debug level is reverted, and the counter is reset.

This parts sounds scary. Time would be enough.

Overall not-so-bad idea.

RZ Updated by Radoslaw Zarzynski 8 months ago Actions #3

Bump up (would be cool if Gemini starts working on that ;-D).

LS Updated by Lumir Sliva 8 months ago Actions #4

  • Status changed from New to In Progress
  • Assignee set to Lumir Sliva

LS Updated by Lumir Sliva 8 months ago ยท Edited Actions #5

Hi all, I prepared this PR to address the tracker: https://github.com/ceph/ceph/pull/68442

It adds a `DebugLevelGuard` that runs on each daemon's periodic tick (classic OSD, Monitor, Crimson OSD). It samples subsystem log levels, and if one sits at/above `high_debug_level_threshold` for longer than `high_debug_level_reset_timeout`, the guard reverts it to the last known safe value and raises a `HIGH_DEBUG_LEVEL` mgr health warning in the meantime.

Key design points:
  • Only the log level is checked, not the gather level (gather stays in memory for crash dumps, doesn't drive I/O).
  • Revert target is the last observed safe value, not the compiled default, so `debug_osd 1/5` stays `1/5` after a revert.
  • Manual lower during the countdown cancels the pending revert.
  • `reset_timeout=0` gives warn-only mode (health warning, no revert) without needing a separate bool.
  • Default disabled (`threshold=0`); must be explicitly opted into.

Example from the smoke run:

$ ceph config set global high_debug_level_threshold 10
$ ceph config set global high_debug_level_reset_timeout 8
$ ceph tell osd.0 config set debug_bluestore 25
# within 1-2 s:
$ ceph health detail
HEALTH_WARN 1 subsystems across 1 daemon(s) have high debug levels (max 25): osd.0
[WRN] HIGH_DEBUG_LEVEL: 1 subsystems across 1 daemon(s) have high debug levels (max 25): osd.0
# after 8 s, in out/osd.0.log:
-1 Auto-reverted debug_bluestore from 25 to 1/5 after 8s (high_debug_level_threshold=10)
# health clears:
$ ceph health
HEALTH_OK
Tested end-to-end on a local vstart lab cluster (MON=1, MGR=1, OSD=1 and MON=1, MGR=1, OSD=3, rebased on ceph/main):
  • Elevate, then health warns with the new "N subsystems across M daemon(s)" summary, then auto-revert to safe value, then health clears.
  • `reset_timeout=0` keeps the warning visible and does not revert. Confirmed.
  • Manual lower during the countdown preserves the user's new value (verified with `debug_rocksdb` set to 2/2 after elevating to 25).
  • Both classic OSD and Monitor paths emit the `HIGH_DEBUG_LEVEL` metric through `mgr.server handle_report daemon_health_metrics`.

Unit coverage: 9 GTest cases in `test_debug_level_guard.cc`. Integration coverage: `qa/workunits/mon/debug_level_guard.sh` plus a `rados/singleton/all/debug-level-guard.yaml` teuthology entry that asserts the health warning appears and clears.

Happy to tune defaults (threshold/timeout) or add more scenarios if reviewers want them.

RZ Updated by Radoslaw Zarzynski 8 months ago Actions #6

  • Pull request ID set to 68442

RZ Updated by Radoslaw Zarzynski 8 months ago Actions #7

  • Status changed from In Progress to Fix Under Review

UB Updated by Upkeep Bot 2 months ago Actions #8

  • Status changed from Fix Under Review to Resolved
  • Merge Commit set to d0a1e79d27780bf1fb7daaa584bda20a8790fef7
  • Fixed In set to v21.3.0-3872-gd0a1e79d27
  • Upkeep Timestamp set to 2026-09-30T22:48:14+00:00
Actions

Also available in: PDF Atom