Files
zoneminder/scripts
Isaac Connor 8fb4ad79e6 perf: restrict zmstats ES resync to monitors with pruned buckets
Two issues with the previous implementation:
  1. Aggregate SELECTs ran GROUP BY MonitorId across the full bucket
     tables every zmstats cycle (default 60s). Events_Month grows for
     weeks; this turned the stats daemon into a constant full-scan
     workload on busy installs.
  2. The per-monitor UPDATE loop X-locked every Event_Summaries row on
     every cycle even when nothing changed, adding avoidable contention
     with the trigger writers this rewrite is supposed to protect.

Capture MonitorIds as we SELECT bucket rows for pruning, then skip the
resync entirely if no rows were pruned. When rows were pruned, restrict
the aggregate SELECTs (WHERE MonitorId IN ...) and the per-monitor
UPDATEs to that touched set. zmaudit remains the periodic deep-resync
safety net for drift in untouched monitors.

Also capture errstr before rollback so the gave-up Error reports the
actual reason instead of an empty string on drivers that clear errstr
on rollback.
2026-05-17 08:50:38 -04:00
..