mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-10 20:42:14 +00:00
In a pathological configuration (essentially unbounded and continually increasing number of campaigns, tenants, coupled with a synthetic 10% rate of triggering drastic bounce automation rules) I observed that tsa could trip over itself when locking the sqlite db to maintain the event history table. This in turn causes delays in responding to the shaping data endpoint, leading to timeout errors in kumod. This commit removes the sqlite-based event_history table that was the source of that contention and replaces it with a much more compact and easier to reason about set of in-memory data structures built around a sharded hash map. This makes it very quick to insert and return the current count when assessing rules with triggering thresholds. This new state is serialized using msgpack and periodically saved in the background, as well as on shutdown.