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

+4-2
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

+1-1
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

+7-7
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

+3-3
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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

+2-2
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_none.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ dummy a b
699699
SET AUTOCOMMIT=0;
700700
START TRANSACTION;
701701
INSERT INTO t1 VALUES (2,2,2);
702-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
702+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
703703
ROLLBACK;
704704
ROLLBACK;
705705
DROP TABLE t1;
@@ -716,7 +716,7 @@ COMMIT;
716716
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
717717
SET AUTOCOMMIT=0;
718718
SELECT * FROM t1 WHERE a > 2 FOR UPDATE;
719-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
719+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.a
720720
ROLLBACK;
721721
ROLLBACK;
722722
DROP TABLE t1;

mysql-test/r/innodb_mysql_lock.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ id value
164164
# Connection con1
165165
SET lock_wait_timeout=1;
166166
ALTER TABLE t1 ADD INDEX idx(value);
167-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
167+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
168168
ALTER TABLE t1 ADD INDEX idx(value);
169-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
169+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
170170
# Connection default
171171
SELECT * FROM t1;
172172
id value

mysql-test/r/innodb_mysql_sync.result

+15-15
Original file line numberDiff line numberDiff line change
@@ -246,23 +246,23 @@ SET DEBUG_SYNC= 'now SIGNAL continue1';
246246
SET DEBUG_SYNC= 'now WAIT_FOR upgraded';
247247
# Now both reads and writes should be blocked
248248
SELECT * FROM t1;
249-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
249+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
250250
INSERT INTO t1 VALUES (4,4);
251-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
251+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
252252
SET DEBUG_SYNC= 'now SIGNAL continue2';
253253
SET DEBUG_SYNC= 'now WAIT_FOR beforecommit';
254254
# Still both reads and writes should be blocked.
255255
SELECT * FROM t1;
256-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
256+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
257257
INSERT INTO t1 VALUES (5,5);
258-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
258+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
259259
SET DEBUG_SYNC= 'now SIGNAL continue3';
260260
SET DEBUG_SYNC= 'now WAIT_FOR binlog';
261261
# Same here.
262262
SELECT * FROM t1;
263-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
263+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
264264
INSERT INTO t1 VALUES (6,6);
265-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
265+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
266266
SET DEBUG_SYNC= 'now SIGNAL continue4';
267267
# Connection default
268268
# Reaping ALTER TABLE ...
@@ -293,14 +293,14 @@ a b
293293
2 2
294294
3 3
295295
INSERT INTO t1 VALUES (4,4);
296-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
296+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
297297
SET DEBUG_SYNC= 'now SIGNAL continue2';
298298
SET DEBUG_SYNC= 'now WAIT_FOR binlog';
299299
# Now both reads and writes should be blocked.
300300
SELECT * FROM t1 limit 1;
301-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
301+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
302302
INSERT INTO t1 VALUES (5,5);
303-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
303+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
304304
SET DEBUG_SYNC= 'now SIGNAL continue3';
305305
# Connection default
306306
# Reaping ALTER TABLE ...
@@ -334,23 +334,23 @@ SET DEBUG_SYNC= 'now SIGNAL continue1';
334334
SET DEBUG_SYNC= 'now WAIT_FOR upgraded';
335335
# Now both reads and writes should be blocked.
336336
SELECT * FROM t1;
337-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
337+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
338338
INSERT INTO t1 VALUES (4,4);
339-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
339+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
340340
SET DEBUG_SYNC= 'now SIGNAL continue2';
341341
SET DEBUG_SYNC= 'now WAIT_FOR beforecommit';
342342
# Same here.
343343
SELECT * FROM t1;
344-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
344+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
345345
INSERT INTO t1 VALUES (5,5);
346-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
346+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
347347
SET DEBUG_SYNC= 'now SIGNAL continue3';
348348
SET DEBUG_SYNC= 'now WAIT_FOR binlog';
349349
# Same here.
350350
SELECT * FROM t1;
351-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
351+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
352352
INSERT INTO t1 VALUES (6,6);
353-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
353+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on table metadata: test.t1
354354
SET DEBUG_SYNC= 'now SIGNAL continue4';
355355
# Connection default
356356
# Reaping ALTER TABLE ...

mysql-test/r/innodb_trx_count.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ i
88
1
99
begin;
1010
update t1 set i=2 where i=1;
11-
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
11+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on record in index: test/t1.PRIMARY
1212
rollback;
1313
commit_all_diff
1414
0

0 commit comments

Comments
 (0)