@@ -2493,170 +2493,6 @@ connection default;
2493
2493
2494
2494
drop table t1;
2495
2495
2496
- --echo #
2497
- --echo # Now, test for a situation in which deadlock involves waiting not
2498
- --echo # only in MDL subsystem but also for TDC. Such deadlocks should be
2499
- --echo # successfully detected. If possible, they should be resolved without
2500
- --echo # resorting to ER_LOCK_DEADLOCK error.
2501
- --echo #
2502
- create table t1(i int);
2503
- create table t2(j int);
2504
-
2505
- --echo #
2506
- --echo # First, let us check how we handle a simple scenario involving
2507
- --echo # waits in MDL and TDC.
2508
- --echo #
2509
- set debug_sync= 'RESET';
2510
-
2511
- connection deadlock_con1;
2512
- --echo # Start a statement, which will acquire SR metadata lock on t1, open it
2513
- --echo # and then stop, before trying to acquire SW lock on t2 and opening it.
2514
- set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
2515
- --echo # Sending:
2516
- --send select * from t1 where i in (select j from t2 for update)
2517
-
2518
- connection deadlock_con2;
2519
- --echo # Wait till the above SELECT stops.
2520
- set debug_sync='now WAIT_FOR parked';
2521
- --echo # The below FLUSH TABLES WITH READ LOCK should acquire
2522
- --echo # SNW locks on t1 and t2 and wait till SELECT closes t1.
2523
- --echo # Sending:
2524
- send flush tables t1, t2 with read lock;
2525
-
2526
- connection deadlock_con3;
2527
- --echo # Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting
2528
- --echo # for SELECT to close t1.
2529
- let $wait_condition=
2530
- select count(*) = 1 from information_schema.processlist
2531
- where state = "Waiting for table flush" and
2532
- info = "flush tables t1, t2 with read lock";
2533
- --source include/wait_condition.inc
2534
-
2535
- --echo # Resume SELECT, so it tries to acquire SW lock on t1 and blocks,
2536
- --echo # creating a deadlock. This deadlock should be detected and resolved
2537
- --echo # by backing-off SELECT. As a result FTWRL should be able to finish.
2538
- set debug_sync='now SIGNAL go';
2539
-
2540
- connection deadlock_con2;
2541
- --echo # Reap FLUSH TABLES WITH READ LOCK.
2542
- reap;
2543
- unlock tables;
2544
-
2545
- connection deadlock_con1;
2546
- --echo # Reap SELECT.
2547
- reap;
2548
-
2549
- --echo #
2550
- --echo # The same scenario with a slightly different order of events
2551
- --echo # which emphasizes that setting correct deadlock detector weights
2552
- --echo # for flush waits is important.
2553
- --echo #
2554
- set debug_sync= 'RESET';
2555
-
2556
- connection deadlock_con2;
2557
- set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go';
2558
-
2559
- --echo # The below FLUSH TABLES WITH READ LOCK should acquire
2560
- --echo # SNW locks on t1 and t2 and wait on debug sync point.
2561
- --echo # Sending:
2562
- send flush tables t1, t2 with read lock;
2563
-
2564
- connection deadlock_con1;
2565
- --echo # Wait till FLUSH TABLE WITH READ LOCK stops.
2566
- set debug_sync='now WAIT_FOR parked';
2567
-
2568
- --echo # Start statement which will acquire SR metadata lock on t1, open
2569
- --echo # it and then will block while trying to acquire SW lock on t2.
2570
- --echo # Sending:
2571
- send select * from t1 where i in (select j from t2 for update);
2572
-
2573
- connection deadlock_con3;
2574
- --echo # Wait till the above SELECT blocks.
2575
- let $wait_condition=
2576
- select count(*) = 1 from information_schema.processlist
2577
- where state = "Waiting for table metadata lock" and
2578
- info = "select * from t1 where i in (select j from t2 for update)";
2579
- --source include/wait_condition.inc
2580
-
2581
- --echo # Resume FLUSH TABLES, so it tries to flush t1, thus creating
2582
- --echo # a deadlock. This deadlock should be detected and resolved by
2583
- --echo # backing-off SELECT. As a result FTWRL should be able to finish.
2584
- set debug_sync='now SIGNAL go';
2585
-
2586
- connection deadlock_con2;
2587
- --echo # Reap FLUSH TABLES WITH READ LOCK.
2588
- reap;
2589
- unlock tables;
2590
-
2591
- connection deadlock_con1;
2592
- --echo # Reap SELECT.
2593
- reap;
2594
-
2595
- --echo #
2596
- --echo # Now a more complex scenario involving two connections
2597
- --echo # waiting for MDL and one for TDC.
2598
- --echo #
2599
- set debug_sync= 'RESET';
2600
-
2601
- connection deadlock_con1;
2602
- --echo # Start a statement which will acquire SR metadata lock on t2, open it
2603
- --echo # and then stop, before trying to acquire SR on t1 and opening it.
2604
- set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
2605
- --echo # Sending:
2606
- send select * from t2, t1;
2607
-
2608
- connection deadlock_con2;
2609
- --echo # Wait till the above SELECT stops.
2610
- set debug_sync='now WAIT_FOR parked';
2611
- --echo # The below FLUSH TABLES WITH READ LOCK should acquire
2612
- --echo # SNW locks on t2 and wait till SELECT closes t2.
2613
- --echo # Sending:
2614
- send flush tables t2 with read lock;
2615
-
2616
- connection deadlock_con3;
2617
- --echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting
2618
- --echo # for SELECT to close t2.
2619
- let $wait_condition=
2620
- select count(*) = 1 from information_schema.processlist
2621
- where state = "Waiting for table flush" and
2622
- info = "flush tables t2 with read lock";
2623
- --source include/wait_condition.inc
2624
-
2625
- --echo # The below DROP TABLES should acquire X lock on t1 and start
2626
- --echo # waiting for X lock on t2.
2627
- --echo # Sending:
2628
- send drop tables t1, t2;
2629
-
2630
- connection default;
2631
- --echo # Wait until DROP TABLES starts waiting for X lock on t2.
2632
- let $wait_condition=
2633
- select count(*) = 1 from information_schema.processlist
2634
- where state = "Waiting for table metadata lock" and
2635
- info = "drop tables t1, t2";
2636
- --source include/wait_condition.inc
2637
-
2638
- --echo # Resume SELECT, so it tries to acquire SR lock on t1 and blocks,
2639
- --echo # creating a deadlock. This deadlock should be detected and resolved
2640
- --echo # by backing-off SELECT. As a result, FTWRL should be able to finish.
2641
- set debug_sync='now SIGNAL go';
2642
-
2643
- connection deadlock_con2;
2644
- --echo # Reap FLUSH TABLES WITH READ LOCK.
2645
- reap;
2646
- --echo # Unblock DROP TABLES.
2647
- unlock tables;
2648
-
2649
- connection deadlock_con3;
2650
- --echo # Reap DROP TABLES.
2651
- reap;
2652
-
2653
- connection deadlock_con1;
2654
- --echo # Reap SELECT. It should emit error about missing table.
2655
- --error ER_NO_SUCH_TABLE
2656
- reap;
2657
-
2658
- connection default;
2659
-
2660
2496
set debug_sync= 'RESET';
2661
2497
2662
2498
disconnect deadlock_con1;
0 commit comments