Monitor impact of rescuing unique constraint error in BillingAccount model
Problem
As a way to resolve the error in https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/7754, we are rescuing the ActiveRecord::RecordNotUnique
exception. This way silently rescues the error and halts the workflow. The scope of this issue is to monitor the impact of rescuing the error and see if a pessimistic locking mechanism is required.
Noting below the after-save actions for the existing instances wherein the exception is being rescued-
- Account IDs not refreshed in
Customers::UpdateBillingAccountService
- Creation of customer account for
sold_to
contact inAccountWorker
The other places where this is used such as RailsAdmin and CustomerFinder
is unlikely to have much of the race condition impact.
Impact so far (from December 22 to December 27):
On staging, I see the race condition occurring more frequently (anywhere between 3 to 48). On production, the frequency is less (between 0-4). The time of the year (decreased billing activity) can also be a factor in production.