openstax / accounts

OpenStax centralized authentication and accounts service

Home Page:https://accounts.openstax.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Accounts] (prodtutor) sessions#help (PG::UniqueViolation) "ERROR: duplicate key value violates unique constraint \"ind...

Dantemss opened this issue · comments

A PG::UniqueViolation occurred in sessions#help:

  ERROR:  duplicate key value violates unique constraint "index_password_reset_codes_on_identity_id"
DETAIL:  Key (identity_id)=(10575) already exists.

  vendor/bundle/ruby/2.2.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/postgresql_adapter.rb:1176:in `get_last_result'

First app line in backtrace is:

app/routines/generate_password_reset_code.rb:17:in `exec'

Likely double clicking the reset password button.

According to my notes (https://github.com/openstax/napkin-notes/blob/master/dante/db/postgres_transaction_isolation.md), the most concurrent solution is to use the exchange transaction retry patch (https://github.com/openstax/exchange/blob/master/lib/transaction_retry_patch.rb) and then remove the :serializable isolation from the routine (since that doesn't seem to work anyway).

@jpslav can we just move the password reset stuff into the identity record?

Seems fixed.