Skip to content

Commit

Permalink
deal with other race case with contact creation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 30, 2017
1 parent 24e035c commit 5339461
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backends/rapidpro/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ func contactForURN(db *sqlx.DB, org OrgID, channelID courier.ChannelID, urn cour
return nil, err
}

// if the returned URN is for a different contact, then we were in a race as well, rollback and start over
if contactURN.ContactID.Int64 != contact.ID.Int64 {
tx.Rollback()
return contactForURN(db, org, channelID, urn, name)
}

// all is well, we created the new contact, commit and move forward
err = tx.Commit()
if err != nil {
return nil, err
Expand Down

0 comments on commit 5339461

Please sign in to comment.