global

def retry_on_uniqueness_violation(&block)

unlikely to happen. In such cases, raising an exception is acceptable.
is deleted before the update and readded before the insert, which is very
retrying will work. It is possible for it to fail again, but only if the row
update and the insert, the insert will fail with a uniqueness error, but
an update affects no rows. In such cases, if a row is inserted between the
This is used to avoid race conditions when using the pattern of inserting when
def retry_on_uniqueness_violation(&block)
  if raises_uniqueness_violation?(&block)
    yield
  end
end