Skip to content
  • Claire's avatar
    Fix error when suspending user with an already-existing canonical email block (#17036) · 02a87431
    Claire authored
    * Fix error when suspending user with an already-existing canonical email block
    
    Fixes #17033
    
    While attempting to create a `CanonicalEmailBlock` with an existing hash would
    raise an `ActiveRecord::RecordNotUnique` error, this being done within a
    transaction would cancel the whole transaction. For this reason, checking for
    uniqueness in Rails would query the database within the transaction and avoid
    invalidating the whole transaction for this reason.
    
    A race condition is still possible, where multiple accounts sharing a canonical
    email would be blocked in concurrent transactions, in which only one would
    succeed, but that is way less likely to happen that the current issue, and can
    always be retried after the first failure, unlike the current situation.
    
    * Add tests
    02a87431