This article introduces the solution case of deadlocks caused by loaddata statements in MySQL to coders. it describes some locking mechanisms in the InnoDB engine data table, you can refer to the deadlocks reported by the next online project to briefly describe the causes, solutions, and related points.
1. Background
This is a project similar to DATA analysis. DATA is completely imported into an InnoDB table using the load data statement. To facilita
First, the preface
MySQL InnoDB, support transaction and row level lock, can use row lock to handle the business such as user's mentioning. The use of MySQL locks sometimes deadlock, to do a good job of deadlock prevention.
Second, MySQL row-level lock
Row-level locks are
If a deadlock occurs, how can this problem be solved? Find the original lock ID and KILL the thread that has been held all the time. But how can we find the thread ID that causes the deadlock among many threads? Since MySQL has developed
If a deadlock occurs, how can this problem be solved? Find the original lock ID a
1. Test descriptionEnvironment Description: RHEL 6.4 x86_64 + MySQL 5.5.37, transaction ISOLATION level RCTest table:Mysql> Show CREATE TABLE t1\g*************************** 1. Row *************************** table:t1create table:create Table ' t1 ' ( ' a ' int (one) not NULL DEFAULT ' 0 ', ' B ' int (one) default NULL, PRIMARY key (' a '), key ' B ' (' B ')) Engine=innodb default charset=utf81 row in Set (0.00 SE CTo test the data in the ta
Find the original MySQL deadlock ID. If a deadlock occurs, how can this problem be solved? Find the original lock ID and KILL the thread that has been held all the time. But how can we find the thread ID that causes the deadlock among many threads? MySQL has been very powerf
Tags: mysqlMySQL Deadlock etc 6 combat problems solved Directory:
Unlocking after the lock table
MySQL connection number is not enough
MySQL Root password modification
Password is correct but not logged in
0 issues with DateTime types
View Table Footprint
Unlocking after the lock tableWhen you do a DML operation on a table, it
Use MySQLInnoDB engine lock mechanism to solve deadlocks:
When I used Show innodb status to check the engine status, I found a deadlock problem:
* ** (1) TRANSACTION:
TRANSACTION 0 677833455, ACTIVE 0 sec, process no 11393, OS thread id 278546 starting index read
Mysql tables in use 1, locked 1
LOCK wait3 lock struct (s), heap size 320
MySQL thread id 83, query
not locked.
The following is the deadlock caused by the MySQL for update.
After analysis, MySQL's InnoDB storage Engine practice Lock is a lock line, but it is locked internally, depending on whether the value of the Where condition and select is only primary KEY or Non-key key index to determine how the lock, such as only the primary key, the lock primary key index, if only a Non-key key, then the lock
for a transaction2. Exclusive Lock: X Lock: SELECT * FROM Test where ... for update; An exclusive read-write lock on one row for a transactionTwo1. View the Deadlock log command: show engine InnoDB status \g; Specific deadlock reference: 1190000009469556Session 1:SELECT * FROM test where id = 1 for update;Session 2:Update Test Set name = "QQ" WHERE id = 1;When Session1 and Session2 are running simultaneou
Mysql deadlock caused by full disk
Today, I encountered a problem because the disk of the machine where mysql is located is full, leading to a mysql deadlock and not even querying the select statement. If I did not read the mysql
Label:Today, there is a problem, because the MySQL machine's disk is full to cause the MySQL deadlock, even the query select can not, but to look at the MySQL log, I really can not find the reason. By show Processlist you can see that the first is an UPDATE statement that requires writing data because the disk is full
This article mainly introduced the MySQL database lock generation reason and the solution, needs the friend can refer to the nextThe database, like the operating system, is a shared resource used by multiple users. When multiple users access data concurrently, in the database, multiple transactions are generated concurrently to access the same data. If the concurrency operation is not controlled, it is possible to read and store incorrect data and com
Tags: ima commit res foreign thread CTS blog Wait baseReprint Address: http://yueliangdao0608.blog.51cto.com/397025/1180917 If you encounter a deadlock, how to solve it? Find the original lock ID, and then kill the thread that has been holding it, but how many threads can find the thread ID that caused the deadlock? MySQL has evolved to the present, is very stron
This article describes how to find the deadlock ID in the MySQL thread, mainly from the data dictionary. For more information, see. If a deadlock occurs, how can this problem be solved? Find the original lock ID and KILL the thread that has been held all the time. but how can we find the thread ID that causes the deadlock
without concurrency, because each transaction is executed serially in MySQL, there are no other transactions in the middle at the same time; when the concurrency is high, the order of statements actually run in MySQL may change to the following:
Tx_num time statement
111 2011-12-12 10:00:00 Delete from ts_column_log_test wherecol_id = 10;
222 2011-12-12:00:00 Delete from ts_column_log_test where col_id = 1
------------------------
LATEST detected DEADLOCK
------------------------
140824 1:01:24
(1) TRANSACTION:
TRANSACTION 110E, active starting SEC index Read # # transaction id=110E, active 73s
MySQL tables in use 1, locked 1
Lock WAIT 3 lock struct (s), Heap size 376, 2 row lock (s) # # There are 2 row locks
MySQL thread ID 1, OS thread handle 0x7
;SELECT * from ' ABCDEFG ' WHERE def=19 and ghi=19 and jkl=19;--Pause, wait for the first half of window B to execute the next sectionINSERT into ' ABCDEFG ' (ABC,DEF,GHI,JKL,MNP) VALUES (' 19 ', 19,19,19,1);COMMIT;Use Memdb;SHOW VARIABLES like '%autocommit% ';SET tx_isolation= ' SERIALIZABLE ';SHOW VARIABLES like '%tx% ';START TRANSACTION;SELECT * from ' ABCDEFG ' WHERE def=18 and ghi=18 and jkl=18;--Pause, etc. the first half of the a window is executed in the next section of theINSERT into '
MySQL Deadlock case analysis and solutionsPhenomenon:Database query:SQL Statement Analysis:Mysql.Concurrent Delete same row record, occasional deadlock.Delete from x_table where id=? Deadlock Analysis:MySQL's transactional support is related to the storage engine, MyISAM does not support transactions, InnoDB supports transactions, and is used for row-level locks
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.