Solved

Are race conditions an issue in mySQL INSERTs?

Posted on 2011-03-02
2
558 Views
Last Modified: 2012-05-11
Hello.  I am new to the concept of race conditions, and most of my tables have numeric primary keys set to auto-increment.  Is this a potential problem?  As in, is it possible that 2 INSERT statements could fire simultaneously on a table and leave me with 2 rows with matching primary keys?
0
Comment
Question by:chaseivey
2 Comments
 
LVL 38

Accepted Solution

by:
Aaron Tomosky earned 65 total points
ID: 35024275
Nope. SQL is made for that stuff.
0
 
LVL 4

Assisted Solution

by:gizmola
gizmola earned 60 total points
ID: 35025676
A primary key is by definition unique, so there's no possibility of that happening.  Additionally AUTO_INCREMENT is inherently built around a table lock that serializes the allocation of new id's to insert statements.

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now