Remove subtransactions in `StatusPage::PublishedIncident`
In #338346 (comment 652623314), we identified the use of subtransactions can cause significant performance issues on PostgreSQL replicas at scale. If a long running transaction occurs, the subtransaction cache may not fit into the working set of memory, which can lead to a context switch storm when PostgreSQL needs to load subtransaction data from disk. While this arguably is a PostgreSQL bug, we should remove subtransactions entirely because they aren't performant at GitLab.com scale, nor are they strictly necessary.
Problem
Avoid using safe_find_or_create_by
in StatusPage::PublishedIncident#track
.
Proposed solution
Use plain StatusPage::PublishedIncident#insert
(which results in INSERT ... ON CONFLICT DO NOTHING
) to avoid subtransactions.
Edited by Peter Leitzen