Skip to content

Commit c2dbe68

Browse files
committed
Add lock information to lock timeout error message
Summary: Currently, on lock timeout, we only give ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction which has no information on what type of lock timed out. This change augments the message with the lock type to say something like ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction: Timeout on index: test/t1.GEN_CLUST_INDEX which shows which type of lock timed out as well as the associated object. There two cases to handle here. For error messages coming from the storage engine, the error is stored onto the transaction, which will get forwarded to the SQL layer for display through `handler::get_error_message`.. For MDL locks in the SQL layer, we are directly using the information in the MDL lock to display the error message. I didn't touch NDB because I didn't bother getting that to build. Test Plan: mtr Reviewers: jkedgar, jtolmer Reviewed By: jtolmer Subscribers: ebergen, webscalesql-eng Differential Revision: https://reviews.facebook.net/D47613
1 parent 1c7af80 commit c2dbe68

File tree

83 files changed

+640
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+640
-479
lines changed

include/thr_lock.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern "C" {
2525
#include <my_list.h>
2626

2727
struct st_thr_lock;
28+
struct TABLE;
2829
extern ulong locks_immediate,locks_waited ;
2930

3031
/*
@@ -99,7 +100,7 @@ typedef struct st_thr_lock_data {
99100
mysql_cond_t *cond;
100101
enum thr_lock_type type;
101102
void *status_param; /* Param to status functions */
102-
void *debug_print_param;
103+
struct TABLE *table;
103104
struct PSI_table *m_psi;
104105
} THR_LOCK_DATA;
105106

@@ -141,7 +142,8 @@ enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data,
141142
void thr_unlock(THR_LOCK_DATA *data);
142143
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
143144
uint count, THR_LOCK_INFO *owner,
144-
ulong lock_wait_timeout);
145+
ulong lock_wait_timeout,
146+
THR_LOCK_DATA **error_pos);
145147
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
146148
void
147149
thr_lock_merge_status(THR_LOCK_DATA **data, uint count);

mysql-test/r/check.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ LOCK TABLE t1 WRITE;
3838
SET lock_wait_timeout= 1;
3939
CHECK TABLE t1;
4040
Table Op Msg_type Msg_text
41-
test.t1 check Error Lock wait timeout exceeded; try restarting transaction
41+
test.t1 check Error Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
4242
test.t1 check status Operation failed
4343
# Connection default
4444
UNLOCK TABLES;

mysql-test/r/concurrent_innodb_safelog.result

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ begin;
4646
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
4747
** do not match the WHERE condition are released.
4848
update t1 set eta=2 where tipo=22;
49-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
49+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
5050
** Release user level name lock from thread 1. This will cause the ULL
5151
** on thread 2 to end its wait.
5252
DO release_lock("hello");
@@ -186,7 +186,7 @@ begin;
186186
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
187187
** do not match the WHERE condition are released.
188188
update t1 set tipo=1 where tipo=2;
189-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
189+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
190190
** Release ULL. This will release the next waiting ULL on thread 2.
191191
DO release_lock("hello");
192192
** The table should still be updated with updates for thread 1 only:
@@ -368,7 +368,7 @@ begin;
368368
** Update the same range which is marked for update on thread 2; this
369369
** will hang because of row locks.
370370
update t1 set tipo=1 where tipo=2;
371-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
371+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
372372
** After the update the table will be unmodified because the previous
373373
** transaction failed and was rolled back.
374374
select * from t1;
@@ -475,7 +475,7 @@ begin;
475475
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
476476
** do not match the WHERE condition are released.
477477
update t1 set tipo=11 where tipo=22;
478-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
478+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
479479
** After the time out the transaction is aborted; no rows should
480480
** have changed.
481481
select * from t1;
@@ -574,7 +574,7 @@ begin;
574574
** Selecting a range for update by table scan will be blocked
575575
** because of on-going transaction on thread 2.
576576
select * from t1 where tipo=1 FOR UPDATE;
577-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
577+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
578578
** connection thread2
579579
** Table will be unchanged and the select command will not be
580580
** blocked:
@@ -653,7 +653,7 @@ delete from t1 where tipo=2;
653653
** connection thread1
654654
begin;
655655
update t1 set tipo=1 where tipo=2;
656-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
656+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
657657
select * from t1;
658658
eta tipo c
659659
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -735,7 +735,7 @@ begin;
735735
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
736736
** do not match the WHERE condition are released.
737737
update t1 set tipo=1 where tipo=22;
738-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
738+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
739739
select * from t1;
740740
eta tipo c
741741
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

mysql-test/r/concurrent_innodb_unsafelog.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ begin;
366366
** Update the same range which is marked for update on thread 2; this
367367
** will hang because of row locks.
368368
update t1 set tipo=1 where tipo=2;
369-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
369+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
370370
** After the update the table will be unmodified because the previous
371371
** transaction failed and was rolled back.
372372
select * from t1;
@@ -571,7 +571,7 @@ begin;
571571
** Selecting a range for update by table scan will be blocked
572572
** because of on-going transaction on thread 2.
573573
select * from t1 where tipo=1 FOR UPDATE;
574-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
574+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
575575
** connection thread2
576576
** Table will be unchanged and the select command will not be
577577
** blocked:
@@ -650,7 +650,7 @@ delete from t1 where tipo=2;
650650
** connection thread1
651651
begin;
652652
update t1 set tipo=1 where tipo=2;
653-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
653+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.GEN_CLUST_INDEX
654654
select * from t1;
655655
eta tipo c
656656
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

mysql-test/r/innodb_mrr.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ dummy a b
700700
SET AUTOCOMMIT=0;
701701
START TRANSACTION;
702702
INSERT INTO t1 VALUES (2,2,2);
703-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
703+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
704704
ROLLBACK;
705705
ROLLBACK;
706706
DROP TABLE t1;
@@ -717,7 +717,7 @@ COMMIT;
717717
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
718718
SET AUTOCOMMIT=0;
719719
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
720-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
720+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
721721
ROLLBACK;
722722
ROLLBACK;
723723
DROP TABLE t1;

mysql-test/r/innodb_mrr_all.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ dummy a b
700700
SET AUTOCOMMIT=0;
701701
START TRANSACTION;
702702
INSERT INTO t1 VALUES (2,2,2);
703-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
703+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
704704
ROLLBACK;
705705
ROLLBACK;
706706
DROP TABLE t1;
@@ -717,7 +717,7 @@ COMMIT;
717717
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
718718
SET AUTOCOMMIT=0;
719719
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
720-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
720+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
721721
ROLLBACK;
722722
ROLLBACK;
723723
DROP TABLE t1;

mysql-test/r/innodb_mrr_cost.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ dummy a b
700700
SET AUTOCOMMIT=0;
701701
START TRANSACTION;
702702
INSERT INTO t1 VALUES (2,2,2);
703-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
703+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
704704
ROLLBACK;
705705
ROLLBACK;
706706
DROP TABLE t1;
@@ -717,7 +717,7 @@ COMMIT;
717717
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
718718
SET AUTOCOMMIT=0;
719719
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
720-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
720+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
721721
ROLLBACK;
722722
ROLLBACK;
723723
DROP TABLE t1;

mysql-test/r/innodb_mrr_cost_all.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ dummy a b
700700
SET AUTOCOMMIT=0;
701701
START TRANSACTION;
702702
INSERT INTO t1 VALUES (2,2,2);
703-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
703+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
704704
ROLLBACK;
705705
ROLLBACK;
706706
DROP TABLE t1;
@@ -717,7 +717,7 @@ COMMIT;
717717
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
718718
SET AUTOCOMMIT=0;
719719
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
720-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
720+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
721721
ROLLBACK;
722722
ROLLBACK;
723723
DROP TABLE t1;

mysql-test/r/innodb_mrr_cost_icp.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ dummy a b
700700
SET AUTOCOMMIT=0;
701701
START TRANSACTION;
702702
INSERT INTO t1 VALUES (2,2,2);
703-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
703+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
704704
ROLLBACK;
705705
ROLLBACK;
706706
DROP TABLE t1;
@@ -717,7 +717,7 @@ COMMIT;
717717
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
718718
SET AUTOCOMMIT=0;
719719
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
720-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
720+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
721721
ROLLBACK;
722722
ROLLBACK;
723723
DROP TABLE t1;

mysql-test/r/innodb_mrr_icp.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ dummy a b
700700
SET AUTOCOMMIT=0;
701701
START TRANSACTION;
702702
INSERT INTO t1 VALUES (2,2,2);
703-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
703+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
704704
ROLLBACK;
705705
ROLLBACK;
706706
DROP TABLE t1;
@@ -717,7 +717,7 @@ COMMIT;
717717
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
718718
SET AUTOCOMMIT=0;
719719
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
720-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
720+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
721721
ROLLBACK;
722722
ROLLBACK;
723723
DROP TABLE t1;

0 commit comments

Comments
 (0)