engine: persist the incident ring (LOGSEARCH) across restarts via a periodic + on-shutdown snapshot event, mirroring stat-counter persistence
All checks were successful
CI / check (push) Successful in 3m44s

This commit is contained in:
Jean Chevronnet 2026-07-19 00:46:14 +00:00
parent 754c5d9e95
commit a10662bbc6
No known key found for this signature in database
9 changed files with 102 additions and 6 deletions

View file

@ -229,6 +229,7 @@ impl Engine {
// Restore persisted stats so they survive a restart.
network.seed_stats(db.persisted_stats());
network.seed_chan_activity(db.persisted_chan_stats());
network.seed_incidents(db.persisted_incidents());
Self {
services,
network,
@ -308,6 +309,18 @@ impl Engine {
}
}
// Snapshot the recent-incident ring (OperServ LOGSEARCH) so it survives a
// restart. Flushed on the same cadence as the stat counters.
pub fn persist_incidents(&mut self) {
let (seq, incidents) = self.network.incidents_snapshot();
if incidents.is_empty() {
return;
}
if let Err(err) = self.db.persist_incidents(seq, incidents) {
tracing::warn!(%err, "failed to persist incidents");
}
}
// Wall-clock seconds, overridable in tests so the time-based FLOOD kicker is
// deterministic.
fn now_secs(&self) -> u64 {
@ -1875,7 +1888,7 @@ fn audit_summary(event: &db::Event) -> Option<String> {
| ChannelMlock { .. } | ChannelDescSet { .. } | ChannelEntryMsgSet { .. } | ChannelUrlSet { .. } | ChannelEmailSet { .. } | ChannelSettingsSet { .. }
| ChannelKickerSet { .. } | ChannelBadwordsSet { .. } | ChannelTriggersSet { .. }
| ChannelTopicSet { .. } | AccountSeen { .. } | ChannelUsed { .. }
| AccountExpiryWarned { .. } | ChannelExpiryWarned { .. } | StatsSet { .. } => return None,
| AccountExpiryWarned { .. } | ChannelExpiryWarned { .. } | StatsSet { .. } | IncidentsSet { .. } => return None,
};
Some(s)
}