Skip to content

feat: coalesce repeated log messages to prevent log floods#29

Merged
tobez merged 5 commits into
mainfrom
log-throttling
Jul 8, 2026
Merged

feat: coalesce repeated log messages to prevent log floods#29
tobez merged 5 commits into
mainfrom
log-throttling

Conversation

@tobez

@tobez tobez commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Repeated per-agent SNMP anomalies and per-connection client churn could
previously drive log output without bound — a misbehaving or hostile agent
could flood the log with thousands of lines per second. This adds windowed
coalescing: the first event per key in a 10-second window logs immediately
with full detail; the rest are counted and rolled up into a single
… repeated=N interval_s=10 line when the window closes.

Storm cost drops to at most one detailed line plus one rollup per 10 s per
key. The UDP send-buffer overflow, previously dropped silently, now gets a
throttled notice so operators can tell sends are being lost; its statistics
counter stays exact and unconditional.

Details

  • Pure clock-injected coalescing primitive, unit-tested with a fake clock.
  • One category per distinct message; per-destination counters are lazily
    allocated only for hosts that actually misbehave, so memory scales with
    misbehaving hosts, not fleet size.
  • Rollups piggyback the existing once-per-second housekeeping tick — no new
    timer machinery. log_debug output is left unthrottled (it's opt-in).

Test plan

  • New C unit tier t/throttle.t (fake-clock primitive + glue), 21 assertions
  • t/logging.t extended: per-destination anomaly coalescing + client-churn coalescing subtests
  • Full suite: 343 tests pass (make test)
  • scan-build clean — No bugs found
  • Clean -Werror build

@tobez tobez merged commit 4ee81c8 into main Jul 8, 2026
3 checks passed
@tobez tobez deleted the log-throttling branch July 8, 2026 10:28
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.

1 participant