Skip to content

Code monitors: fix concurrent transactions

Administrator requested to merge cc/synchronize-snapshot into main

Created by: camdencheek

This mostly fixes an issue I was seeing with creating code monitors for multiple repos where we'd get weird conn busy errors. Basically, the issue is that transactions can't be used concurrently and the database.DB passed into this function is a transaction in CreateCodeMonitor. The jobs run in parallel, which triggers these errors sporadically.

The fix is incomplete and hacky, but I'm struggling to figure out a way to not pass in a transaction here or to guarantee that the transaction is never used concurrently, so I'm opting for the quick fix for the moment.

Test plan

Tested manually that creating a code monitor for many repos doesn't cause conn busy (at least not nearly as much).

Merge request reports

Loading