Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:40:53+00:00 2026-06-17T18:40:53+00:00

I get an exception and I want to understand why. I’ve created a git

  • 0

I get an exception and I want to understand why. I’ve created a git repo so anyone can test it.

The rails app is fresh with Devise installed on it.

Running the app and this script that try to create the same user:

1000.times do
  fork do
    `curl -d "user[email]=your@mail.com&user[password]=pwd&user[password_confirmation]=pwd" localhost:3000/users`
  end
end

I get the follow exception:

An ActiveRecord::RecordNotUnique occurred in registrations#create:

Mysql2::Error: Duplicate entry 'your@mail.com' for key 'index_users_on_email': INSERT INTO `users` (`authentication_token`, `confirmation_sent_at`, `confirmation_token`, `confirmed_at`, `created_at`, `current_sign_in_at`, `current_sign_in_ip`, `email`, `encrypted_password`, `failed_attempts`, `last_sign_in_at`, `last_sign_in_ip`, `locked_at`, `remember_created_at`, `reset_password_sent_at`, `reset_password_token`, `sign_in_count`, `unconfirmed_email`, `unlock_token`, `updated_at`) VALUES (NULL, '2013-01-24 16:48:23', 'GQwbJzsawxRsbvhp1LkR', NULL, '2013-01-24 16:48:23', NULL, NULL, 'your@mail.com', '$2a$10$koMNiiZQuhkeWhmYV8PtcOUlvi6rZHTKMs82MGWNa2M/GsUQ0cIHO', 0, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, '2013-01-24 16:48:23')
activerecord (3.2.11) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'

Why I get this exception and not a validation error? If I try to create an user with an email that is already used from the web page “http://localhost:3000/users/sign_up” I dont get this exception but a validation error…

If I run the script without fork (request are sequential), I get no error.

Seems a race conditions problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:40:54+00:00Added an answer on June 17, 2026 at 6:40 pm

    In your script you try to create 1000 users all with the email “your@mail.com”. You have a uniqueness constraint on your user email index (correctly – you only want one user per email address). The second time it tries to create a user with that email you will get the error.

    As you are forking your request the validates_uniqueness_of validation provided by devise may be succeeding because it queries for another record with the same email. But, by the time the record is actually written, another record may exist.

    For example,

    1. Request 1 checks for existing email “your@mail.com” – okay
    2. Request 2 checks for existing email “your@mail.com” – okay
    3. Request 1 writes record with email “your@mail.com” – okay
    4. Request 2 writes record with email “your@mail.com” – uniqueness violation.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get exception of page load, but still have not results on
when I want to retrieve date from access , I get an exception error
I want to get Default Windows Forms Unhandled-Exception Dialog whenever my C# application encounters
After 3.3 -> 4.1 migration I get exception on the resulting page File /fast/buildout-cache/eggs/plone.app.viewletmanager-2.0.2-py2.6.egg/plone/app/viewletmanager/manager.py,
I get the exception from the title when I run my app. What it
There is a thing that I can not understand about Cursor.getType() , can anyone
I want to test this route I made on Sinatra: get '/party' do begin
I can't understand this. I want to use an OCX from this vendor http://www.mobyt.it/
maybe you could help me understand why I get an unhandled exception Invalid XAML
In a Spring + Hibernate + JTA project I'm trying to get exception handling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.