Simple way to deal with race conditions in Rails
tl;dr
Wrap all .first_or_create!/find_or_create_by! calls in retryable block.
⛶Retryable.retryable(
on: [ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid]
) do .. end
Di...