SlideShare a Scribd company logo
1 of 28
Download to read offline
DEADLOCKS
in MySQL
ā€žEverything happens for a reason.
Britney Spears
ACID
atomicity
consistency
isolation
durability
ATOMICITY
āž¤ requires that each transaction
be "all or nothingā€
āž¤ if one part of the transaction
fails, then the entire
transaction fails, and the
database state is left
unchanged
CONSISTENCY
āž¤ ensures that any transaction
will bring the database from
one valid state to another
ISOLATION
āž¤ ensures that the concurrent
execution of transactions
results in a system state that
would be obtained if
transactions were executed
sequentially, i.e., one after the
other.Ā 
DURABILITY
āž¤ ensures that once a
transaction has been
committed, it will remain so,
even in the event of power
loss,Ā crashes, or errors
ā€žTrust is built with consistency.
Lincoln Chafee
TRANSACTION ISOLATION LEVELS:
āž¤ read uncommitted
āž¤ Transaction B will seeĀ allĀ the mutations that transaction A makes
āž¤ read committed (default in PostgreSQL)
āž¤ Transaction B will seeĀ all the mutations that transaction A commit
āž¤ repeatable read (default in MySQL)
āž¤ Transaction B will not seeĀ any mutations that transaction A commit
āž¤ serializable(the ā€žparanoidā€ level)
āž¤ Even selects in transaction B will be locked by the mutations that transaction A makes
READ UNCOMMITTED
> start transaction;
> select * from test; (val = 8)
> update test set val = val + 1; (val = 9)
> rollback;
> set session transaction isolation level read
uncommitted;
> start transaction;
> select * from test; (val = 8)ā€Ø
> select * from test; (val = 9, dirty read)
> select * from test; (val = 8)
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
READ COMMITTED
> start transaction;
> select * from test; (val = 8)
> update test set val = val + 1; (val = 9)
> commit;
> set session transaction isolation level read
committed;
> start transaction;
> select * from test; (val = 8)ā€Ø
> select * from test; (val = 8, no dirty read)
> select * from test; (val = 9, committed read)
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
REPEATABLE READ - CASE 1
> start transaction;
> select * from test; (val = 8)
> update test set val = val + 1; (val = 9)
> commit;
> set session transaction isolation level
repeatable read;
> start transaction;
> select * from test; (val = 8)ā€Ø
> select * from test; (val = 8)
> select * from test; (val = 8, repeatable read!)
> commit;
> select * from test; (val = 9)
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
REPEATABLE READ - CASE 2
> start transaction;
> select * from test; (val = 8)
> update test set val = val + 1; (val = 9)
> commit;
> set session transaction isolation level
repeatable read;
> start transaction;
> select * from test; (val = 8)ā€Ø
> select * from test; (val = 8, repeatable read!)
> update test set val = val + 1; (val = 10)
> commit;
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
REPEATABLE READ - CASE 3
> start transaction;
> select * from test; (val = 8)
> into into test values (2, 9);
> commit;
> set session transaction isolation level
repeatable read;
> start transaction;
> select * from test; (val = 8)ā€Ø
> select * from test; (val = 8, repeatable read!)
> update test set val = val + 1; (val = 10, 9)
> Query OK, 2 rows affected
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
SERIALIZABLE - CASE 1
> start transaction;
> select * from test; (val = 8)
> update test set val = val + 1; (val = 9)
> commit;
> set session transaction isolation level
serializable;
> start transaction;
> select * from test; ā€Ø
> LOCKED, NO OUTPUT
> (val = 9)
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
SERIALIZABLE - CASE 2
> start transaction;
> select * from test; (val = 8)
> update test set val = val + 1; (val = 9)
> LOCKED, NO OUTPUT
> Query OK, 1 row updated!
> set session transaction isolation level
serializable;
> start transaction;
> select * from test; (val = 8)ā€Ø
> commit;
TRANSACTION A: TRANSACTION B:
> select * from test;
+----+-----+
| id | val |
+----+-----+
| 1 | 8 |
+----+-----+
ā€žSuccess isn't always about greatness.
It's about consistency. Consistent
hard work leads to success. Greatness
will come.
Dwayne Johnson
LOCK MODES: SHARED, EXCLUSIVE
āž¤ SHARED
āž¤ [row level] allow multiple users to read data, but do not allow any users to
change that data
āž¤ EXCLUSIVE
āž¤ [row/table level] allows only one user/connection to update a particular piece
of data (insert, update, and delete)
EXCLUSIVE LOCKS ARE ALWAYS FIRST
FOREIGN KEYS - SPECIAL CASE
āž¤ during insert shared locks will be added to parent rows from
all foreign keys
āž¤ during update shared locks will be added to parent rows from
only foreign keys being updated (mysql is smart enough)
SHARED LOCK
> start transaction;
> insert into role values (2, 1, ā€™userā€™);
> commit;
> start transaction;
> insert into role values (3, 1, ā€™guestā€™);
> commit;
TRANSACTION A: TRANSACTION B:
Transaction A set exclusive lock to row ID 2 in table role and shared lock is set to row ID 1
in table user. Transaction B set exclusive lock to row ID 3 in table role and shared lock to
row ID 1 in table user. Summary: two shared locks were set on the same row with ID 1 in
table user.
> select * from user;
+----+--------+
| id | name |
+----+--------+
| 1 | test |
+----+--------+
> select * from role;+----+----------+-------+| id | user_id | name |+----+----------+-------+| 1 | 1 | admin |+----+----------+-------+
EXCLUSIVE LOCK
> start transaction;
> update user set name = ā€™test editā€™;
> commit;
> start transaction;
> update user set name = ā€™test 2 editā€™;ā€Ø
> LOCKED, NO OUTPUT
> 1 rows updated;
> commit;
TRANSACTION A: TRANSACTION B:
Transaction A set exclusive lock on row ID 1 in table User. Transaction B try to set exclusive
lock on the same row in table User and need to wait till transaction A is committed and
exclusive lock will be released.
> select * from user;
+----+--------+
| id | name |
+----+--------+
| 1 | test |
+----+--------+
> select * from role;+----+----------+-------+| id | user_id | name |+----+----------+-------+| 1 | 1 | admin |+----+----------+-------+
DEAD
LOCK
example
DEAD LOCK
> start transaction;
> insert into role values (2, 1, ā€™userā€™);
> update user set name = ā€™test editā€™;
> LOCKED, NO OUTPUT
> start transaction;
> insert into role values (3, 1, ā€™guestā€™);
> update user set name = ā€™test editā€™;ā€Ø
> DEADLOCK! ROLLBACK!
TRANSACTION A: TRANSACTION B:
> select * from user;
+----+--------+
| id | name |
+----+--------+
| 1 | test |
+----+--------+
> select * from role;+----+----------+-------+| id | user_id | name |+----+----------+-------+| 1 | 1 | admin |+----+----------+-------+
Transaction A set exclusive lock on row ID 2 in table Role and shared lock on row ID 1 in
table User. Transaction B do the same (exclusive lock ID 3 in table Role, shared lock ID 1 in
table User). Transaction A try to set exclusive lock on row ID 1 in table User and need to
wait till Transaction B will release shared lock. Transaction B try to set also exclusive lock
on row ID 1 in table User - mysql engine detects DEAD Lock and rollback transaction B.
HOW TO AVOID DEAD LOCKS
āž¤ Use UPDATEs before INSERTs
āž¤ Use SELECT ā€¦ FOR UPDATE (it will set exclusive lock on all
selected rows)
āž¤ This will impact on performance - all other transaction will
wait till exclusive lock will be released
āž¤ Change isolation level to serializable
āž¤ Consider removing foreign keys (soft deletable will keep your
database consistent)
āž¤ Attention! There are always some raw removes!! If not
business will ļ¬nd the use case for that!!
HOW TO ANALYZE DEAD LOCKS
āž¤ mysql> SHOW ENGINE INNODB STATUS;
āž¤ you must be logged to mysql as a root user
------------------------
LATEST DETECTED DEADLOCK
------------------------
2017-10-13 08:30:08 0x7f7b03396700
*** (1) TRANSACTION:
TRANSACTION 1809, ACTIVE 35 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 5 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1
MySQL thread id 6, OS thread handle 140166312064768, query id 46 localhost test updating
update user set name = 'artur'
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 25 page no 3 n bits 72 index PRIMARY of table `test`.`user` trx id 1809 lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 1; hex 31; asc 1;;
1: len 6; hex 00000000070e; asc ;;
2: len 7; hex ae000001220110; asc " ;;
3: len 5; hex 726166616c; asc rafal;;
*** (2) TRANSACTION:
TRANSACTION 1814, ACTIVE 21 sec starting index read
mysql tables in use 1, locked 1
5 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1
MySQL thread id 7, OS thread handle 140166311798528, query id 47 localhost test updating
update user set name = 'bogdan'
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 25 page no 3 n bits 72 index PRIMARY of table `test`.`user` trx id 1814 lock mode S locks rec but not gap
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 1; hex 31; asc 1;;
1: len 6; hex 00000000070e; asc ;;
2: len 7; hex ae000001220110; asc " ;;
3: len 5; hex 726166616c; asc rafal;;
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 25 page no 3 n bits 72 index PRIMARY of table `test`.`user` trx id 1814 lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 1; hex 31; asc 1;;
1: len 6; hex 00000000070e; asc ;;
2: len 7; hex ae000001220110; asc " ;;
3: len 5; hex 726166616c; asc rafal;;
HOW TO READ LOGS
āž¤ keep in mind that the order in logs is diļ¬€erent than in mysql
[259] [2017-08-31 16:20:56] doctrine.DEBUG: "START TRANSACTION" []
[259] [2017-08-31 16:20:56] doctrine.DEBUG: INSERT INTO sales_order_activity (actor,
target, title, published, changeset, object, verb, target_id, object_iā€¦
[263] [2017-08-31 16:20:56] doctrine.DEBUG: "START TRANSACTION" []
[259] [2017-08-31 16:20:56] doctrine.DEBUG: UPDATE sales_orders SET cached_total = ?,
updated_at = ? WHERE id = ? [875,"2017-08-31 16:20:56ā€,ā€d72a1d81-f3a4ā€¦
[263] [2017-08-31 16:20:56] doctrine.DEBUG: INSERT INTO sales_order_activity (actor,
target, title, published, changeset, object, verb, target_id, object_iā€¦
[263] [2017-08-31 16:20:56] doctrine.DEBUG: UPDATE sales_orders SET cached_total = ?,
updated_at = ? WHERE id = ? [875,"2017-08-31 16:20:56ā€,ā€d72a1d81-f3a4ā€¦.
[263] [2017-08-31 16:20:56] request.CRITICAL: Uncaught PHP Exception
DoctrineDBALDBALException: "An exception occurred while executing 'UPDATE
sales_ordeā€¦
āž¤ Thanks for watching!
āž¤ Rafał Książek, IT Leader

More Related Content

What's hot

The Ring programming language version 1.8 book - Part 32 of 202
The Ring programming language version 1.8 book - Part 32 of 202The Ring programming language version 1.8 book - Part 32 of 202
The Ring programming language version 1.8 book - Part 32 of 202Mahmoud Samir Fayed
Ā 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developersInSync Conference
Ā 
Maximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestMaximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestPythian
Ā 
The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189Mahmoud Samir Fayed
Ā 
The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30Mahmoud Samir Fayed
Ā 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101Sveta Smirnova
Ā 
P RƁ T I C A N E C T A S 1641 1651
P RƁ T I C A  N E C T A S 1641 1651P RƁ T I C A  N E C T A S 1641 1651
P RƁ T I C A N E C T A S 1641 1651Fxx
Ā 
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84Mahmoud Samir Fayed
Ā 
2010 sectool
2010 sectool2010 sectool
2010 sectoolWayne Evans
Ā 

What's hot (9)

The Ring programming language version 1.8 book - Part 32 of 202
The Ring programming language version 1.8 book - Part 32 of 202The Ring programming language version 1.8 book - Part 32 of 202
The Ring programming language version 1.8 book - Part 32 of 202
Ā 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developers
Ā 
Maximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestMaximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digest
Ā 
The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189The Ring programming language version 1.6 book - Part 29 of 189
The Ring programming language version 1.6 book - Part 29 of 189
Ā 
The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30The Ring programming language version 1.4 book - Part 7 of 30
The Ring programming language version 1.4 book - Part 7 of 30
Ā 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101
Ā 
P RƁ T I C A N E C T A S 1641 1651
P RƁ T I C A  N E C T A S 1641 1651P RƁ T I C A  N E C T A S 1641 1651
P RƁ T I C A N E C T A S 1641 1651
Ā 
The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84The Ring programming language version 1.2 book - Part 16 of 84
The Ring programming language version 1.2 book - Part 16 of 84
Ā 
2010 sectool
2010 sectool2010 sectool
2010 sectool
Ā 

Similar to Deadlocks in MySQL

Rails Concurrency Gotchas
Rails Concurrency GotchasRails Concurrency Gotchas
Rails Concurrency Gotchasmarcostoledo
Ā 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01Karam Abuataya
Ā 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11gfcamachob
Ā 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command linePriti Solanki
Ā 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
Ā 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesDave Stokes
Ā 
Replication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDReplication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDMydbops
Ā 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)Dave Stokes
Ā 
Indexes From the Concept to Internals
Indexes From the Concept to InternalsIndexes From the Concept to Internals
Indexes From the Concept to InternalsDeiby GĆ³mez
Ā 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionSveta Smirnova
Ā 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
Ā 
PHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAPHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAAmit Kumar Singh
Ā 
Pro PostgreSQL
Pro PostgreSQLPro PostgreSQL
Pro PostgreSQLRobert Treat
Ā 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitDave Stokes
Ā 
Major features postgres 11
Major features postgres 11Major features postgres 11
Major features postgres 11EDB
Ā 
Passbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managmentPassbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managmentThierry Gayet
Ā 

Similar to Deadlocks in MySQL (20)

Rails Concurrency Gotchas
Rails Concurrency GotchasRails Concurrency Gotchas
Rails Concurrency Gotchas
Ā 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Ā 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
Ā 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command line
Ā 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Ā 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Ā 
Replication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDReplication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTID
Ā 
Stored procedure
Stored procedureStored procedure
Stored procedure
Ā 
Stored procedure
Stored procedureStored procedure
Stored procedure
Ā 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
Ā 
Indexes From the Concept to Internals
Indexes From the Concept to InternalsIndexes From the Concept to Internals
Indexes From the Concept to Internals
Ā 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
Ā 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
Ā 
PHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAPHP tips by a MYSQL DBA
PHP tips by a MYSQL DBA
Ā 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
Ā 
Pro PostgreSQL
Pro PostgreSQLPro PostgreSQL
Pro PostgreSQL
Ā 
Instalar MySQL CentOS
Instalar MySQL CentOSInstalar MySQL CentOS
Instalar MySQL CentOS
Ā 
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source SummitMySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
Ā 
Major features postgres 11
Major features postgres 11Major features postgres 11
Major features postgres 11
Ā 
Passbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managmentPassbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managment
Ā 

Recently uploaded

āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men šŸ”mahisagaršŸ” Esc...
āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men  šŸ”mahisagaršŸ”   Esc...āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men  šŸ”mahisagaršŸ”   Esc...
āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men šŸ”mahisagaršŸ” Esc...amitlee9823
Ā 
Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...amitlee9823
Ā 
Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...amitlee9823
Ā 
āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men šŸ”ThrissuršŸ” Escor...
āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men  šŸ”ThrissuršŸ”   Escor...āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men  šŸ”ThrissuršŸ”   Escor...
āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men šŸ”ThrissuršŸ” Escor...amitlee9823
Ā 
Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...amitlee9823
Ā 
āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men šŸ”DindigulšŸ” Escor...
āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men  šŸ”DindigulšŸ”   Escor...āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men  šŸ”DindigulšŸ”   Escor...
āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men šŸ”DindigulšŸ” Escor...amitlee9823
Ā 
Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...amitlee9823
Ā 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
Ā 
Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...
Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...
Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...amitlee9823
Ā 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectBoston Institute of Analytics
Ā 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
Ā 
Call Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night Stand
Call Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night StandCall Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night Stand
Call Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night Standamitlee9823
Ā 
Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...amitlee9823
Ā 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
Ā 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
Ā 
Call Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service BangaloreCall Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangaloreamitlee9823
Ā 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
Ā 

Recently uploaded (20)

āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men šŸ”mahisagaršŸ” Esc...
āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men  šŸ”mahisagaršŸ”   Esc...āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men  šŸ”mahisagaršŸ”   Esc...
āž„šŸ” 7737669865 šŸ”ā–» mahisagar Call-girls in Women Seeking Men šŸ”mahisagaršŸ” Esc...
Ā 
Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ā˜Ž 7737669865ā˜Ž Book Your One night Stand (B...
Ā 
Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Bangalore ...
Ā 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Ā 
āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men šŸ”ThrissuršŸ” Escor...
āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men  šŸ”ThrissuršŸ”   Escor...āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men  šŸ”ThrissuršŸ”   Escor...
āž„šŸ” 7737669865 šŸ”ā–» Thrissur Call-girls in Women Seeking Men šŸ”ThrissuršŸ” Escor...
Ā 
Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Indiranagar Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Ā 
āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men šŸ”DindigulšŸ” Escor...
āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men  šŸ”DindigulšŸ”   Escor...āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men  šŸ”DindigulšŸ”   Escor...
āž„šŸ” 7737669865 šŸ”ā–» Dindigul Call-girls in Women Seeking Men šŸ”DindigulšŸ” Escor...
Ā 
Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Call Girls Bommasandra Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service B...
Ā 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
Ā 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Ā 
Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...
Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...
Mg Road Call Girls Service: šŸ“ 7737669865 šŸ“ High Profile Model Escorts | Banga...
Ā 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
Ā 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Ā 
Call Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night Stand
Call Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night StandCall Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night Stand
Call Girls In Doddaballapur Road ā˜Ž 7737669865 šŸ„µ Book Your One night Stand
Ā 
Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Ser...
Ā 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
Ā 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Ā 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Ā 
Call Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service BangaloreCall Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Call Girls Begur Just Call šŸ‘— 7737669865 šŸ‘— Top Class Call Girl Service Bangalore
Ā 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Ā 

Deadlocks in MySQL

  • 2. ā€žEverything happens for a reason. Britney Spears
  • 4. ATOMICITY āž¤ requires that each transaction be "all or nothingā€ āž¤ if one part of the transaction fails, then the entire transaction fails, and the database state is left unchanged
  • 5. CONSISTENCY āž¤ ensures that any transaction will bring the database from one valid state to another
  • 6. ISOLATION āž¤ ensures that the concurrent execution of transactions results in a system state that would be obtained if transactions were executed sequentially, i.e., one after the other.Ā 
  • 7. DURABILITY āž¤ ensures that once a transaction has been committed, it will remain so, even in the event of power loss,Ā crashes, or errors
  • 8. ā€žTrust is built with consistency. Lincoln Chafee
  • 9. TRANSACTION ISOLATION LEVELS: āž¤ read uncommitted āž¤ Transaction B will seeĀ allĀ the mutations that transaction A makes āž¤ read committed (default in PostgreSQL) āž¤ Transaction B will seeĀ all the mutations that transaction A commit āž¤ repeatable read (default in MySQL) āž¤ Transaction B will not seeĀ any mutations that transaction A commit āž¤ serializable(the ā€žparanoidā€ level) āž¤ Even selects in transaction B will be locked by the mutations that transaction A makes
  • 10. READ UNCOMMITTED > start transaction; > select * from test; (val = 8) > update test set val = val + 1; (val = 9) > rollback; > set session transaction isolation level read uncommitted; > start transaction; > select * from test; (val = 8)ā€Ø > select * from test; (val = 9, dirty read) > select * from test; (val = 8) TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 11. READ COMMITTED > start transaction; > select * from test; (val = 8) > update test set val = val + 1; (val = 9) > commit; > set session transaction isolation level read committed; > start transaction; > select * from test; (val = 8)ā€Ø > select * from test; (val = 8, no dirty read) > select * from test; (val = 9, committed read) TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 12. REPEATABLE READ - CASE 1 > start transaction; > select * from test; (val = 8) > update test set val = val + 1; (val = 9) > commit; > set session transaction isolation level repeatable read; > start transaction; > select * from test; (val = 8)ā€Ø > select * from test; (val = 8) > select * from test; (val = 8, repeatable read!) > commit; > select * from test; (val = 9) TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 13. REPEATABLE READ - CASE 2 > start transaction; > select * from test; (val = 8) > update test set val = val + 1; (val = 9) > commit; > set session transaction isolation level repeatable read; > start transaction; > select * from test; (val = 8)ā€Ø > select * from test; (val = 8, repeatable read!) > update test set val = val + 1; (val = 10) > commit; TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 14. REPEATABLE READ - CASE 3 > start transaction; > select * from test; (val = 8) > into into test values (2, 9); > commit; > set session transaction isolation level repeatable read; > start transaction; > select * from test; (val = 8)ā€Ø > select * from test; (val = 8, repeatable read!) > update test set val = val + 1; (val = 10, 9) > Query OK, 2 rows affected TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 15. SERIALIZABLE - CASE 1 > start transaction; > select * from test; (val = 8) > update test set val = val + 1; (val = 9) > commit; > set session transaction isolation level serializable; > start transaction; > select * from test; ā€Ø > LOCKED, NO OUTPUT > (val = 9) TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 16. SERIALIZABLE - CASE 2 > start transaction; > select * from test; (val = 8) > update test set val = val + 1; (val = 9) > LOCKED, NO OUTPUT > Query OK, 1 row updated! > set session transaction isolation level serializable; > start transaction; > select * from test; (val = 8)ā€Ø > commit; TRANSACTION A: TRANSACTION B: > select * from test; +----+-----+ | id | val | +----+-----+ | 1 | 8 | +----+-----+
  • 17. ā€žSuccess isn't always about greatness. It's about consistency. Consistent hard work leads to success. Greatness will come. Dwayne Johnson
  • 18. LOCK MODES: SHARED, EXCLUSIVE āž¤ SHARED āž¤ [row level] allow multiple users to read data, but do not allow any users to change that data āž¤ EXCLUSIVE āž¤ [row/table level] allows only one user/connection to update a particular piece of data (insert, update, and delete)
  • 19. EXCLUSIVE LOCKS ARE ALWAYS FIRST
  • 20. FOREIGN KEYS - SPECIAL CASE āž¤ during insert shared locks will be added to parent rows from all foreign keys āž¤ during update shared locks will be added to parent rows from only foreign keys being updated (mysql is smart enough)
  • 21. SHARED LOCK > start transaction; > insert into role values (2, 1, ā€™userā€™); > commit; > start transaction; > insert into role values (3, 1, ā€™guestā€™); > commit; TRANSACTION A: TRANSACTION B: Transaction A set exclusive lock to row ID 2 in table role and shared lock is set to row ID 1 in table user. Transaction B set exclusive lock to row ID 3 in table role and shared lock to row ID 1 in table user. Summary: two shared locks were set on the same row with ID 1 in table user. > select * from user; +----+--------+ | id | name | +----+--------+ | 1 | test | +----+--------+ > select * from role;+----+----------+-------+| id | user_id | name |+----+----------+-------+| 1 | 1 | admin |+----+----------+-------+
  • 22. EXCLUSIVE LOCK > start transaction; > update user set name = ā€™test editā€™; > commit; > start transaction; > update user set name = ā€™test 2 editā€™;ā€Ø > LOCKED, NO OUTPUT > 1 rows updated; > commit; TRANSACTION A: TRANSACTION B: Transaction A set exclusive lock on row ID 1 in table User. Transaction B try to set exclusive lock on the same row in table User and need to wait till transaction A is committed and exclusive lock will be released. > select * from user; +----+--------+ | id | name | +----+--------+ | 1 | test | +----+--------+ > select * from role;+----+----------+-------+| id | user_id | name |+----+----------+-------+| 1 | 1 | admin |+----+----------+-------+
  • 24. DEAD LOCK > start transaction; > insert into role values (2, 1, ā€™userā€™); > update user set name = ā€™test editā€™; > LOCKED, NO OUTPUT > start transaction; > insert into role values (3, 1, ā€™guestā€™); > update user set name = ā€™test editā€™;ā€Ø > DEADLOCK! ROLLBACK! TRANSACTION A: TRANSACTION B: > select * from user; +----+--------+ | id | name | +----+--------+ | 1 | test | +----+--------+ > select * from role;+----+----------+-------+| id | user_id | name |+----+----------+-------+| 1 | 1 | admin |+----+----------+-------+ Transaction A set exclusive lock on row ID 2 in table Role and shared lock on row ID 1 in table User. Transaction B do the same (exclusive lock ID 3 in table Role, shared lock ID 1 in table User). Transaction A try to set exclusive lock on row ID 1 in table User and need to wait till Transaction B will release shared lock. Transaction B try to set also exclusive lock on row ID 1 in table User - mysql engine detects DEAD Lock and rollback transaction B.
  • 25. HOW TO AVOID DEAD LOCKS āž¤ Use UPDATEs before INSERTs āž¤ Use SELECT ā€¦ FOR UPDATE (it will set exclusive lock on all selected rows) āž¤ This will impact on performance - all other transaction will wait till exclusive lock will be released āž¤ Change isolation level to serializable āž¤ Consider removing foreign keys (soft deletable will keep your database consistent) āž¤ Attention! There are always some raw removes!! If not business will ļ¬nd the use case for that!!
  • 26. HOW TO ANALYZE DEAD LOCKS āž¤ mysql> SHOW ENGINE INNODB STATUS; āž¤ you must be logged to mysql as a root user ------------------------ LATEST DETECTED DEADLOCK ------------------------ 2017-10-13 08:30:08 0x7f7b03396700 *** (1) TRANSACTION: TRANSACTION 1809, ACTIVE 35 sec starting index read mysql tables in use 1, locked 1 LOCK WAIT 5 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1 MySQL thread id 6, OS thread handle 140166312064768, query id 46 localhost test updating update user set name = 'artur' *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 25 page no 3 n bits 72 index PRIMARY of table `test`.`user` trx id 1809 lock_mode X waiting Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0 0: len 1; hex 31; asc 1;; 1: len 6; hex 00000000070e; asc ;; 2: len 7; hex ae000001220110; asc " ;; 3: len 5; hex 726166616c; asc rafal;; *** (2) TRANSACTION: TRANSACTION 1814, ACTIVE 21 sec starting index read mysql tables in use 1, locked 1 5 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 1 MySQL thread id 7, OS thread handle 140166311798528, query id 47 localhost test updating update user set name = 'bogdan' *** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 25 page no 3 n bits 72 index PRIMARY of table `test`.`user` trx id 1814 lock mode S locks rec but not gap Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0 0: len 1; hex 31; asc 1;; 1: len 6; hex 00000000070e; asc ;; 2: len 7; hex ae000001220110; asc " ;; 3: len 5; hex 726166616c; asc rafal;; *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 25 page no 3 n bits 72 index PRIMARY of table `test`.`user` trx id 1814 lock_mode X waiting Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0 0: len 1; hex 31; asc 1;; 1: len 6; hex 00000000070e; asc ;; 2: len 7; hex ae000001220110; asc " ;; 3: len 5; hex 726166616c; asc rafal;;
  • 27. HOW TO READ LOGS āž¤ keep in mind that the order in logs is diļ¬€erent than in mysql [259] [2017-08-31 16:20:56] doctrine.DEBUG: "START TRANSACTION" [] [259] [2017-08-31 16:20:56] doctrine.DEBUG: INSERT INTO sales_order_activity (actor, target, title, published, changeset, object, verb, target_id, object_iā€¦ [263] [2017-08-31 16:20:56] doctrine.DEBUG: "START TRANSACTION" [] [259] [2017-08-31 16:20:56] doctrine.DEBUG: UPDATE sales_orders SET cached_total = ?, updated_at = ? WHERE id = ? [875,"2017-08-31 16:20:56ā€,ā€d72a1d81-f3a4ā€¦ [263] [2017-08-31 16:20:56] doctrine.DEBUG: INSERT INTO sales_order_activity (actor, target, title, published, changeset, object, verb, target_id, object_iā€¦ [263] [2017-08-31 16:20:56] doctrine.DEBUG: UPDATE sales_orders SET cached_total = ?, updated_at = ? WHERE id = ? [875,"2017-08-31 16:20:56ā€,ā€d72a1d81-f3a4ā€¦. [263] [2017-08-31 16:20:56] request.CRITICAL: Uncaught PHP Exception DoctrineDBALDBALException: "An exception occurred while executing 'UPDATE sales_ordeā€¦
  • 28. āž¤ Thanks for watching! āž¤ Rafał Książek, IT Leader