~ubuntu-branches/ubuntu/trusty/mysql-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_4threads_deadlock.test

  • Committer: Package Import Robot
  • Author(s): dann frazier
  • Date: 2015-06-15 12:11:36 UTC
  • mfrom: (40.1.5 trusty-security)
  • Revision ID: package-import@ubuntu.com-20150615121136-52ax3qkv2ajblhst
Tags: 5.5.43-0ubuntu0.14.04.2
Introduce full memory barrier support for arm64 and ppc64el to fix
corruption/hang issues (LP: #1427406).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###############################################################################
 
2
# Bug#17283409  4-WAY DEADLOCK: ZOMBIES, PURGING BINLOGS, SHOW PROCESSLIST,
 
3
#                        SHOW BINLOGS
 
4
# Problem:  A deadlock was occuring when 4 threads were involved in acquiring
 
5
#                locks
 
6
#     Thread 1: Dump thread ( Slave is reconnecting, so on Master, a new dump
 
7
#                    thread is trying kill zombie dump threads. It acquired
 
8
#                    thread's LOCK_thd_data and it is about to acquire
 
9
#                    mysys_var->current_mutex ( which LOCK_log)
 
10
#     Thread 2: Application thread is executing show binlogs and acquired
 
11
#                    LOCK_log and it is about to acquire LOCK_index.
 
12
#     Thread 3: Applicaiton thread is executing Purge binary logs and acquired
 
13
#                    LOCK_index and it is about to acquire LOCK_thread_count.
 
14
#     Thread 4: Application thread is executing show processlist and acquired
 
15
#                    LOCK_thread_count and it is about to acquire zombie dump
 
16
#                    thread's LOCK_thd_data.
 
17
#     Deadlock : Thread 1 -> Thread 2 -> Thread 3-> Thread 4 -> Thread 1
 
18
# The same above deadlock was observed when thread 4 is replaced with another
 
19
# thread which is executing 'SELECT * FROM information_schema.processlist'
 
20
# command and acquired LOCK_thread_count and it is about to acquire zombie
 
21
# dump thread's LOCK_thd_data.
 
22
# Fix: Introuced a new lock (Lock_thread_remove) which will guard the thread
 
23
# deletion (exit process) and the same lock is used in show processlist
 
24
# execution instead of LOCK_thread_count. i.e., After the patch, Server allows
 
25
# new threads to join the system but it will not any threads to execute its
 
26
# 'cleanup' process.  Now the new lock order is: LOCK_thread_remove ->
 
27
# LOCK_thd_data -> LOCK_log -> LOCK_index -> LOCK_thread_count Both the above
 
28
# scenarios are tested with the below test code and it proves that there is no
 
29
# deadlock after the fix.
 
30
###############################################################################
 
31
--source include/have_debug_sync.inc
 
32
--source include/have_binlog_format_statement.inc
 
33
--source include/master-slave.inc
 
34
 
 
35
connect(master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
 
36
connect(master3,127.0.0.1,root,,test,$MASTER_MYPORT,);
 
37
--connection master
 
38
# Create atleast one binary log, otherwise purge logs command, show binary
 
39
# logs command do not hit the DEBUG_SYNC points.
 
40
FLUSH LOGS;
 
41
SET @save_debug=@@global.debug;
 
42
SET GLOBAL DEBUG='+d,before_dump_thread_acquires_current_mutex,processlist_acquiring_dump_threads_LOCK_thd_data';
 
43
 
 
44
# Iteration 1 with "SHOW PROCESSLIST command"
 
45
# Iteration 2 with "SELECT * FROM information_schema.processlist"
 
46
--let $iter=2
 
47
while ($iter)
 
48
{
 
49
  --connection slave
 
50
  --source include/stop_slave.inc
 
51
  --source include/start_slave.inc
 
52
  # Thread 1
 
53
  --connection master
 
54
  --echo "Wait_for dump_thread_signal"
 
55
  SET DEBUG_SYNC='now WAIT_FOR dump_thread_signal';
 
56
 
 
57
  # Thread 2
 
58
  --connection master1
 
59
  SET DEBUG_SYNC='show_binlogs_after_lock_log_before_lock_index SIGNAL parked1 WAIT_FOR go';
 
60
  --send SHOW BINARY LOGS
 
61
 
 
62
  --connection master
 
63
  echo "Wait_for parked1";
 
64
  SET DEBUG_SYNC='now WAIT_FOR parked1';
 
65
 
 
66
  # Thread 3
 
67
  --connection master2
 
68
  SET DEBUG_SYNC='purge_logs_after_lock_index_before_thread_count SIGNAL parked2 WAIT_FOR go';
 
69
  --send PURGE BINARY LOGS BEFORE '9999-12-31'
 
70
 
 
71
  --connection master
 
72
  echo "Wait_for parked2";
 
73
  SET DEBUG_SYNC='now WAIT_FOR parked2';
 
74
 
 
75
  # Thread 4
 
76
  --connection master3
 
77
  SET DEBUG_SYNC='processlist_after_LOCK_thd_count_before_LOCK_thd_data SIGNAL parked3 WAIT_FOR go';
 
78
  if ($iter == 1)
 
79
  {
 
80
    --let $query=SHOW PROCESSLIST
 
81
  }
 
82
  if ($iter == 2)
 
83
  {
 
84
    --let $query=SELECT * FROM information_schema.processlist
 
85
  }
 
86
  --send_eval $query
 
87
 
 
88
  --connection master
 
89
  echo "Wait_for parked3";
 
90
  SET DEBUG_SYNC='now WAIT_FOR parked3';
 
91
 
 
92
  --connection master
 
93
  SET DEBUG_SYNC='now SIGNAL go';
 
94
 
 
95
  # Output of each command vary depends on other tests ran in suite(output vary
 
96
  # in Pb2 runs), so lets ignore output. Anyways, we are interested in seeing
 
97
  # that there is no deadlock.
 
98
  --disable_result_log
 
99
  --connection master1
 
100
  --reap
 
101
  --connection master2
 
102
  --reap
 
103
  --connection master3
 
104
  --reap
 
105
  --enable_result_log
 
106
 
 
107
  --dec $iter
 
108
}
 
109
 
 
110
--echo "Cleanup"
 
111
--disconnect master2
 
112
--disconnect master3
 
113
 
 
114
--connection master
 
115
SET DEBUG_SYNC='RESET';
 
116
SET GLOBAL DEBUG=@save_debug;
 
117
source include/rpl_end.inc;