Wrap query in transaction
This alleviates current locking issues.
Related to swh/infra/sysadm-environment#4228 (closed)
Test Plan
swh/infra/sysadm-environment#4228 (closed)
Corrupt objects are popping up now (and growing fast):
Tue 31 May 2022 11:01:14 AM CEST (every 2s)
+-------------------------------+-------+
| now | count |
+-------------------------------+-------+
| 2022-05-31 09:01:14.233113+00 | 1620 |
+-------------------------------+-------+
(1 row)
+-------------------------------+-------+
| now | count |
+-------------------------------+-------+
| 2022-05-31 09:01:54.394741+00 | 3233 |
+-------------------------------+-------+
(1 row)
Time: 6.463 ms
Migrated from D7914 (view on Phabricator)