Deadlock retries

Retry transaction on deadlock error.
If none of those words make sense, what I'm wondering is if the code can be reformulated like so:

```ruby
Appearance.transaction do
  last_appearance = get_first_unanswered_appearance(visitor, offset)
  if last_appearance.nil?
    prompt = choose_prompt(:algorithm => params[:algorithm])
    begin
      appearance = self.site.record_appearance(visitor, prompt)
    rescue
      raise unless error.message =~ /Deadlock found when trying to get lock/ and retry_count < max_retries
      retry_count += 1
      logger.info "Retry ##{retry_count} after deadlock: #{error.inspect}"
      retry
    end
  else
    # only display a new prompt and new appearance if the old prompt has not been voted on
    appearance = last_appearance
    prompt = appearance.prompt
  end
end
```