The way we are expiring reports is terrible and very transaction-unfriendly. I started an attempt to fix this in
but I don’t have time to finish this. The idea is to break the deletion into small transactions (batches).
BUT I don’t think that this is the root cause of Ruby processes burning CPU. The reports expiration rather creates transaction errors than loops with some hard work.