ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '[email protected]' for key 'users.index_users_on_email' (ActiveRecord::RecordNotUnique)

Open
#13,084 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
15/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
mysql, rails, ruby
Domain
backend, database

Research direction

The trace starts in Auth::RegistrationsController#create and ends in the Mysql2 client, so the duplicate-email race is raised during the insert. Read the registration create action and the User model's email validation, then check the index_users_on_email unique index in the schema. The issue does not say what the fix should be, so confirm the intended behaviour with maintainers before writing code.

Written by the indexing model from the issue text.

Description

Error

Duplicate entry '[email protected]' for key 'users.index_users_on_email' (Mysql2::Error)

Stack trace

mysql2/client.rb:146 in _query
mysql2/client.rb:146 in block in Mysql2::Client#query
mysql2/client.rb:145 in Thread.handle_interrupt
mysql2/client.rb:145 in query
active_record/connection_adapters/mysql2/database_statements.rb:98 in block (2 levels) in ActiveRecord::ConnectionAdapters::Mysql2::DatabaseStatements#raw_execute
active_record/connection_adapters/abstract_adapter.rb:1029 in block in ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection
active_support/concurrency/null_lock.rb:9 in synchronize
active_record/connection_adapters/abstract_adapter.rb:998 in with_raw_connection
active_record/connection_adapters/mysql2/database_statements.rb:96 in block in ActiveRecord::ConnectionAdapters::Mysql2::DatabaseStatements#raw_execute
active_support/notifications/instrumenter.rb:58 in instrument

Tracking Details

Dominant language
Ruby
Stars
554
Forks
172
Avg merge
20h 23m
Merged PRs (30d)
73

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from exercism/website

All issues in exercism/website

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.