Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How mysql locks tables for updates and inserts

Posted on 2014-01-08
1
Medium Priority
?
422 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
1 Comment
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month6 days, 17 hours left to enroll

782 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