Solved

Are race conditions an issue in mySQL INSERTs?

Posted on 2011-03-02
2
550 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

10 Experts available now in Live!

Get 1:1 Help Now