Solved

Are race conditions an issue in mySQL INSERTs?

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

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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