Solved

How mysql locks tables for updates and inserts

Posted on 2014-01-08
1
415 Views
Last Modified: 2014-01-08
Hello

I am trying to get a better understanding of how mysql locks tables during inserts and updates.

If one database connecting is writing/updating a record and creating a row-level lock on that record and another database connection then tries to access the same record:

1) can second database access the record even if it is for a select? I presume not
2) How long does it wait for the record to be released or how many retries does it have before it gives up. Can these properties be configured in some database variables?

Thanks
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 39765622
REFMAN:
http://dev.mysql.com/doc/refman/5.6/en/commit.html (TRANSACTION isolation)
http://dev.mysql.com/doc/refman/5.6/en/lock-tables.html (LOCK tables)
http://dev.mysql.com/doc/refman/5.5/en/innodb-lock-modes.html (INNODB lock modes)

The above should help, but to answer your questions my understanding is another session can read from locked row using read consistent transactions.  It will give the committed value of the record and not the change in process.

Regarding the wait time, there is the innodb_lock_wait_timeout configuration.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Error Code 2 31
Unwanted output from my query 5 53
MySQL 6 48
Calling an MySQL Stored Prodecure from a php function with input and output parameters 6 49
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Creating and Managing Databases with phpMyAdmin in cPanel.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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