Retry User#store to recover from race condition
Retry User#store to recover from race condition

This is super ugly, but I'm tried of constantly restarting the dyno
every time someone new joins the Slack team.

Some day I'll fix it more elegantly, but for now, this should cover it.

The error occurs when someone joins the Slack team and joins #chit-chat
at the exact same time (which is the normal flow of events for a new
user). I get two messages at the same time and handle them with
EM.defer. Using `first_or_create` blows up because in between the time
"first" discovers nothing, and "create" tries to INSERT a record, the
other thread has already finished inserting, and thus we get a duplicate
constraint violation.

Simply retrying once would be good enough for "first" to find a record
and be done.

zacstewart/tech404logs,zacstewart/tech404-search,zacstewart/tech404-search,zacstewart/tech404logs,zacstewart/tech404logs,zacstewart/tech404-search