Merge lp:~vlad-lesin/percona-server/5.6-sql_timeout into lp:percona-server/5.6

Proposed by Vlad Lesin
Status: Work in progress
Proposed branch: lp:~vlad-lesin/percona-server/5.6-sql_timeout
Merge into: lp:percona-server/5.6
Diff against target: 3089 lines (+857/-266)
61 files modified
Percona-Server/mysql-test/r/mysqld--help-notwin.result (+2/-0)
Percona-Server/mysql-test/r/percona_sql_timeout.result (+120/-0)
Percona-Server/mysql-test/suite/sys_vars/r/sql_timeout_basic.result (+151/-0)
Percona-Server/mysql-test/suite/sys_vars/t/sql_timeout_basic.test (+194/-0)
Percona-Server/mysql-test/t/percona_sql_timeout.test (+82/-0)
Percona-Server/sql/binlog.cc (+3/-3)
Percona-Server/sql/debug_sync.cc (+12/-12)
Percona-Server/sql/event_queue.cc (+3/-3)
Percona-Server/sql/event_scheduler.cc (+1/-1)
Percona-Server/sql/filesort.cc (+4/-7)
Percona-Server/sql/ha_ndbcluster.cc (+12/-12)
Percona-Server/sql/ha_ndbcluster_binlog.cc (+14/-14)
Percona-Server/sql/handler.cc (+5/-5)
Percona-Server/sql/item_func.cc (+10/-5)
Percona-Server/sql/item_subselect.cc (+1/-1)
Percona-Server/sql/lock.cc (+2/-2)
Percona-Server/sql/log.cc (+2/-2)
Percona-Server/sql/log_event.cc (+1/-1)
Percona-Server/sql/mysqld.cc (+2/-2)
Percona-Server/sql/opt_range.cc (+1/-1)
Percona-Server/sql/records.cc (+3/-3)
Percona-Server/sql/rpl_gtid_execution.cc (+2/-2)
Percona-Server/sql/rpl_gtid_state.cc (+1/-1)
Percona-Server/sql/rpl_master.cc (+2/-2)
Percona-Server/sql/rpl_rli.cc (+5/-5)
Percona-Server/sql/rpl_rli_pdb.cc (+9/-9)
Percona-Server/sql/rpl_slave.cc (+9/-9)
Percona-Server/sql/signal_handler.cc (+1/-1)
Percona-Server/sql/sp.cc (+2/-2)
Percona-Server/sql/sp_head.cc (+6/-6)
Percona-Server/sql/sp_instr.cc (+1/-1)
Percona-Server/sql/sp_rcontext.cc (+1/-1)
Percona-Server/sql/sql_admin.cc (+1/-1)
Percona-Server/sql/sql_base.cc (+5/-5)
Percona-Server/sql/sql_cache.cc (+2/-2)
Percona-Server/sql/sql_class.cc (+15/-14)
Percona-Server/sql/sql_class.h (+31/-4)
Percona-Server/sql/sql_connect.cc (+4/-4)
Percona-Server/sql/sql_db.cc (+5/-5)
Percona-Server/sql/sql_delete.cc (+8/-8)
Percona-Server/sql/sql_executor.cc (+12/-12)
Percona-Server/sql/sql_insert.cc (+27/-27)
Percona-Server/sql/sql_join_buffer.cc (+4/-4)
Percona-Server/sql/sql_load.cc (+9/-9)
Percona-Server/sql/sql_optimizer.cc (+2/-2)
Percona-Server/sql/sql_parse.cc (+20/-12)
Percona-Server/sql/sql_planner.cc (+2/-2)
Percona-Server/sql/sql_prepare.cc (+1/-1)
Percona-Server/sql/sql_reload.cc (+2/-2)
Percona-Server/sql/sql_servers.cc (+3/-3)
Percona-Server/sql/sql_show.cc (+5/-5)
Percona-Server/sql/sql_table.cc (+3/-3)
Percona-Server/sql/sql_update.cc (+8/-8)
Percona-Server/sql/sys_vars.cc (+6/-0)
Percona-Server/sql/table.cc (+1/-1)
Percona-Server/storage/innobase/row/row0mysql.cc (+1/-1)
Percona-Server/storage/myisam/ha_myisam.cc (+6/-6)
Percona-Server/storage/myisam/mi_check.c (+5/-5)
Percona-Server/storage/myisam/myisamchk.c (+2/-4)
Percona-Server/storage/myisam/myisamdef.h (+1/-1)
Percona-Server/storage/myisam/sort.c (+2/-2)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/5.6-sql_timeout
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Needs Fixing
Review via email: mp+142497@code.launchpad.net

Description of the change

New system variable "SQL_TIMEOUT" allows to set limit for query execution time.
If this limit is exceeded the query is killed. SQL_TIMEOUT can be global or
session variable.

The timeout expiration is checked on each db-thread killed state check. If timeout
expires the function that returns thread killed status will return the value which
corresponds to "killed query" status.

Jenkins: http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/19
Clean 5.6: http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/20

There can be some issues during merging as THD::killed was renamed to THD::killed_status and became private. But there are getter THD::get_killed() and setter THD::set_killed() which can be used to resolve issues if some new code work with THD::killed.

To post a comment you must log in.
311. By Vlad Lesin

New system variable "SQL_TIMEOUT" allows to set limit for query execution time.
If this limit is exceeded the query is killed. SQL_TIMEOUT can be global or
session variable.

The timeout expiration is checked on each db-thread killed state check. If timeout
expires the function that returns thread killed status will return the value which
corresponds to "killed query" status.

Revision history for this message
Vlad Lesin (vlad-lesin) wrote :

Failed perfschema.threads_mysql test is fixed now.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Vlad,

  - generally I would use check_killed() instead of get_killed(). yes,
    that would be a bit inconsistent naming with set_killed(), but that
    would also make porting APC easier, should we need to do so.
  - mysqld--help-win.result also needs an adjustment
  - setting sql_timeout_expire in mysql_parse() prevents the feature
    from working with client API prepared statements. this check should
    be done in dispatch_command()
  - doing it in dispatch_command() will also make statement-based
    replication immune to sql_timeout. which is good.
  - many lines use tabs for indentation. you can get them with the
    following command:

  bzr diff -c-1 | grep "+\t"

  - changes in merge_buffers() in filesort.cc break the logic it used
    previously, i.e. check the killed state on each iteration in the
    "while" loop, unless param->not_killable is set.

    What we do now is: check the killed state before executing the loop,
    reset it if param->not_killable is set, then check the same value
    inside the loop. See how that code has been changed in MariaDB to
    support APC.

  - same problem as above in storage/myisam/sort.c

  - in Interruptible_wait::wait() we check for the killed status, but
    only after waiting for the full timeout value, which means up to 5
    seconds. Why not do a similar check as with the m_abs_timeout? In
    this case you don't even need a call to m_thd->get_killed() as it
    will be checked by the caller.

  - another problem from the above code is that checking get_killed()
    and resetting the error in Interruptible_wait::wait() returns a
    normal status to the user. I.e. SELECT SLEEP(N) should fail "ERROR
    1317 (70100): Query execution was interrupted" when the timeout is
    exceeded, but it doesn't. Same with user-level locks.

  - in get_killed(), I'd rewrite it like this to not rely on how smart
    is the compiler:

    if (!sql_timeout_expire)
      return killed_status;
    return (my_micro_time() >= sql_timeout_expire) ? THD::KILL_QUERY :
                                                     killed_status;

  - I wonder if we really need my_micro_time() for this. my_time() has
    1 second resolution (which is sufficient in this case) and is also
    faster.

  - in MyISAM code, I would use thd_killed() and keep the killed_ptr()
    name in the same way it is implemented in MariaDB.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Vlad,

Please also update the BP. It should contain everything Hrvoje needs to know to document the feature.

Unmerged revisions

311. By Vlad Lesin

New system variable "SQL_TIMEOUT" allows to set limit for query execution time.
If this limit is exceeded the query is killed. SQL_TIMEOUT can be global or
session variable.

The timeout expiration is checked on each db-thread killed state check. If timeout
expires the function that returns thread killed status will return the value which
corresponds to "killed query" status.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Percona-Server/mysql-test/r/mysqld--help-notwin.result'
--- Percona-Server/mysql-test/r/mysqld--help-notwin.result 2012-12-04 08:24:59 +0000
+++ Percona-Server/mysql-test/r/mysqld--help-notwin.result 2013-01-09 13:41:38 +0000
@@ -894,6 +894,7 @@
894 replication.894 replication.
895 --sql-mode=name Syntax: sql-mode=mode[,mode[,mode...]]. See the manual895 --sql-mode=name Syntax: sql-mode=mode[,mode[,mode...]]. See the manual
896 for the complete list of valid sql modes896 for the complete list of valid sql modes
897 --sql-timeout=# Timeout in seconds to wait before killing query.
897 --stored-program-cache=# 898 --stored-program-cache=#
898 The soft upper limit for number of cached stored routines899 The soft upper limit for number of cached stored routines
899 for one connection.900 for one connection.
@@ -1233,6 +1234,7 @@
1233sort-buffer-size 2621441234sort-buffer-size 262144
1234sporadic-binlog-dump-fail FALSE1235sporadic-binlog-dump-fail FALSE
1235sql-mode NO_ENGINE_SUBSTITUTION1236sql-mode NO_ENGINE_SUBSTITUTION
1237sql-timeout 0
1236stored-program-cache 2561238stored-program-cache 256
1237symbolic-links FALSE1239symbolic-links FALSE
1238sync-binlog 01240sync-binlog 0
12391241
=== added file 'Percona-Server/mysql-test/r/percona_sql_timeout.result'
--- Percona-Server/mysql-test/r/percona_sql_timeout.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/percona_sql_timeout.result 2013-01-09 13:41:38 +0000
@@ -0,0 +1,120 @@
1SLEEP(1)
20
3SLEEP(1000)
41
5SLEEP(2)
60
7SLEEP(1)
80
9SLEEP(1000)
101
11SLEEP(2)
120
13SLEEP(1)
140
15SLEEP(1000)
161
17SLEEP(2)
180
19SLEEP(1)
200
21SLEEP(1000)
221
23SLEEP(2)
240
25SLEEP(1)
260
27SLEEP(1000)
281
29SLEEP(2)
300
31SLEEP(1)
320
33SLEEP(1000)
341
35SLEEP(2)
360
37SLEEP(1)
380
39SLEEP(1000)
401
41SLEEP(2)
420
43SLEEP(1)
440
45SLEEP(1000)
461
47SLEEP(2)
480
49SLEEP(1)
500
51SLEEP(1000)
521
53SLEEP(2)
540
55SLEEP(1)
560
57SLEEP(1000)
581
59SLEEP(2)
600
61SLEEP(1)
620
63SLEEP(1000)
641
65SLEEP(2)
660
67SLEEP(1)
680
69SLEEP(1000)
701
71SLEEP(2)
720
73SLEEP(1)
740
75SLEEP(1000)
761
77SLEEP(2)
780
79SLEEP(1)
800
81SLEEP(1000)
821
83SLEEP(2)
840
85SLEEP(1)
860
87SLEEP(1000)
881
89SLEEP(2)
900
91SLEEP(1)
920
93SLEEP(1000)
941
95SLEEP(2)
960
97SLEEP(1)
980
99SLEEP(1000)
1001
101SLEEP(2)
1020
103SLEEP(1)
1040
105SLEEP(1000)
1061
107SLEEP(2)
1080
109SLEEP(1)
1100
111SLEEP(1000)
1121
113SLEEP(2)
1140
115SLEEP(1)
1160
117SLEEP(1000)
1181
119SLEEP(2)
1200
0121
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/sql_timeout_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/sql_timeout_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/sql_timeout_basic.result 2013-01-09 13:41:38 +0000
@@ -0,0 +1,151 @@
1SET @start_global_value = @@global.sql_timeout;
2SELECT @start_global_value;
3@start_global_value
40
5SET @start_session_value = @@session.sql_timeout;
6SELECT @start_session_value;
7@start_session_value
80
9'#--------------------FN_DYNVARS_083_01-------------------------#'
10SET @@global.sql_timeout = 100;
11SET @@global.sql_timeout = DEFAULT;
12SELECT @@global.sql_timeout;
13@@global.sql_timeout
140
15SET @@session.sql_timeout = 200;
16SET @@session.sql_timeout = DEFAULT;
17SELECT @@session.sql_timeout;
18@@session.sql_timeout
190
20'#--------------------FN_DYNVARS_083_03-------------------------#'
21SET @@global.sql_timeout = 100;
22SELECT @@global.sql_timeout;
23@@global.sql_timeout
24100
25SET @@global.sql_timeout = 200;
26SELECT @@global.sql_timeout;
27@@global.sql_timeout
28200
29SET @@global.sql_timeout = 65536;
30SELECT @@global.sql_timeout;
31@@global.sql_timeout
3265536
33SET @@global.sql_timeout = 4294967295;
34SELECT @@global.sql_timeout;
35@@global.sql_timeout
364294967295
37SET @@global.sql_timeout = 4294967294;
38SELECT @@global.sql_timeout;
39@@global.sql_timeout
404294967294
41'#--------------------FN_DYNVARS_083_04-------------------------#'
42SET @@session.sql_timeout = 100;
43SELECT @@session.sql_timeout;
44@@session.sql_timeout
45100
46SET @@session.sql_timeout = 200;
47SELECT @@session.sql_timeout;
48@@session.sql_timeout
49200
50SET @@session.sql_timeout = 4294967295;
51SELECT @@session.sql_timeout;
52@@session.sql_timeout
534294967295
54SET @@session.sql_timeout = 4294967294;
55SELECT @@session.sql_timeout;
56@@session.sql_timeout
574294967294
58SET @@session.sql_timeout = 65535;
59SELECT @@session.sql_timeout;
60@@session.sql_timeout
6165535
62'#------------------FN_DYNVARS_083_05-----------------------#'
63SET @@global.sql_timeout = 0;
64SELECT @@global.sql_timeout;
65@@global.sql_timeout
660
67SET @@global.sql_timeout = -1024;
68Warnings:
69Warning 1292 Truncated incorrect sql_timeout value: '-1024'
70SELECT @@global.sql_timeout;
71@@global.sql_timeout
720
73SET @@global.sql_timeout = 65530.34;
74ERROR 42000: Incorrect argument type to variable 'sql_timeout'
75SELECT @@global.sql_timeout;
76@@global.sql_timeout
770
78SET @@global.sql_timeout = test;
79ERROR 42000: Incorrect argument type to variable 'sql_timeout'
80SELECT @@global.sql_timeout;
81@@global.sql_timeout
820
83SET @@session.sql_timeout = 0;
84SELECT @@session.sql_timeout;
85@@session.sql_timeout
860
87SET @@session.sql_timeout = -2;
88Warnings:
89Warning 1292 Truncated incorrect sql_timeout value: '-2'
90SELECT @@session.sql_timeout;
91@@session.sql_timeout
920
93SET @@session.sql_timeout = 65530.34;
94ERROR 42000: Incorrect argument type to variable 'sql_timeout'
95SELECT @@session.sql_timeout;
96@@session.sql_timeout
970
98SET @@session.sql_timeout = test;
99ERROR 42000: Incorrect argument type to variable 'sql_timeout'
100SELECT @@session.sql_timeout;
101@@session.sql_timeout
1020
103'#------------------FN_DYNVARS_083_06-----------------------#'
104SELECT @@global.sql_timeout = VARIABLE_VALUE
105FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
106WHERE VARIABLE_NAME='sql_timeout';
107@@global.sql_timeout = VARIABLE_VALUE
1081
109'#------------------FN_DYNVARS_083_07-----------------------#'
110SELECT @@session.sql_timeout = VARIABLE_VALUE
111FROM INFORMATION_SCHEMA.SESSION_VARIABLES
112WHERE VARIABLE_NAME='sql_timeout';
113@@session.sql_timeout = VARIABLE_VALUE
1141
115'#------------------FN_DYNVARS_083_08-----------------------#'
116SET @@global.sql_timeout = FALSE;
117SELECT @@global.sql_timeout;
118@@global.sql_timeout
1190
120'#---------------------FN_DYNVARS_083_09----------------------#'
121SET @@global.sql_timeout = 100;
122SELECT @@sql_timeout = @@global.sql_timeout;
123@@sql_timeout = @@global.sql_timeout
1240
125'#---------------------FN_DYNVARS_083_10----------------------#'
126SET @@sql_timeout = 1000;
127SELECT @@sql_timeout = @@local.sql_timeout;
128@@sql_timeout = @@local.sql_timeout
1291
130SELECT @@local.sql_timeout = @@session.sql_timeout;
131@@local.sql_timeout = @@session.sql_timeout
1321
133'#---------------------FN_DYNVARS_083_11----------------------#'
134SET sql_timeout = 100;
135SELECT @@sql_timeout;
136@@sql_timeout
137100
138SELECT local.sql_timeout;
139ERROR 42S02: Unknown table 'local' in field list
140SELECT session.sql_timeout;
141ERROR 42S02: Unknown table 'session' in field list
142SELECT sql_timeout = @@session.sql_timeout;
143ERROR 42S22: Unknown column 'sql_timeout' in 'field list'
144SET @@global.sql_timeout = @start_global_value;
145SELECT @@global.sql_timeout;
146@@global.sql_timeout
1470
148SET @@session.sql_timeout = @start_session_value;
149SELECT @@session.sql_timeout;
150@@session.sql_timeout
1510
0152
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/sql_timeout_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/sql_timeout_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/sql_timeout_basic.test 2013-01-09 13:41:38 +0000
@@ -0,0 +1,194 @@
1############mysql-test\suite\sysvars\t\sql_timeout_basic.test##################
2# #
3# Variable Name: sql_timeout #
4# Scope: GLOBAL | SESSION #
5# Access Type: Dynamic #
6# Data Type: numeric #
7# Default Value: 0 #
8# Range: 1-4294967295 #
9# #
10# #
11# Creation Date: 2012-02-08 #
12# Author: Vlad Lesin #
13# #
14# Description: Test Cases of Dynamic System Variable sql_timeout #
15# that checks the behavior of this variable in the following ways#
16# * Default Value #
17# * Valid & Invalid values #
18# * Scope & Access method #
19# * Data Integrity #
20# #
21# Reference: none #
22# https://blueprints.launchpad.net/percona-server/+spec/sql-timeout #
23# #
24# #
25###############################################################################
26
27############################################################
28# START OF sql_timeout TESTS #
29############################################################
30
31
32#############################################################
33# Save initial value #
34#############################################################
35
36SET @start_global_value = @@global.sql_timeout;
37SELECT @start_global_value;
38SET @start_session_value = @@session.sql_timeout;
39SELECT @start_session_value;
40
41
42--echo '#--------------------FN_DYNVARS_083_01-------------------------#'
43#################################################################
44# Display the DEFAULT value of sql_timeout #
45#################################################################
46
47SET @@global.sql_timeout = 100;
48SET @@global.sql_timeout = DEFAULT;
49SELECT @@global.sql_timeout;
50
51SET @@session.sql_timeout = 200;
52SET @@session.sql_timeout = DEFAULT;
53SELECT @@session.sql_timeout;
54
55--echo '#--------------------FN_DYNVARS_083_03-------------------------#'
56###########################################################################
57# Change the value of sql_timeout to a valid value for GLOBAL Scope #
58###########################################################################
59
60SET @@global.sql_timeout = 100;
61SELECT @@global.sql_timeout;
62SET @@global.sql_timeout = 200;
63SELECT @@global.sql_timeout;
64SET @@global.sql_timeout = 65536;
65SELECT @@global.sql_timeout;
66SET @@global.sql_timeout = 4294967295;
67SELECT @@global.sql_timeout;
68SET @@global.sql_timeout = 4294967294;
69SELECT @@global.sql_timeout;
70
71
72--echo '#--------------------FN_DYNVARS_083_04-------------------------#'
73############################################################################
74# Change the value of sql_timeout to a valid value for SESSION Scope #
75############################################################################
76SET @@session.sql_timeout = 100;
77SELECT @@session.sql_timeout;
78SET @@session.sql_timeout = 200;
79SELECT @@session.sql_timeout;
80SET @@session.sql_timeout = 4294967295;
81SELECT @@session.sql_timeout;
82SET @@session.sql_timeout = 4294967294;
83SELECT @@session.sql_timeout;
84SET @@session.sql_timeout = 65535;
85SELECT @@session.sql_timeout;
86
87
88--echo '#------------------FN_DYNVARS_083_05-----------------------#'
89#############################################################
90# Change the value of sql_timeout to an invalid value #
91#############################################################
92
93SET @@global.sql_timeout = 0;
94SELECT @@global.sql_timeout;
95SET @@global.sql_timeout = -1024;
96SELECT @@global.sql_timeout;
97--Error ER_WRONG_TYPE_FOR_VAR
98SET @@global.sql_timeout = 65530.34;
99SELECT @@global.sql_timeout;
100--Error ER_WRONG_TYPE_FOR_VAR
101SET @@global.sql_timeout = test;
102SELECT @@global.sql_timeout;
103
104SET @@session.sql_timeout = 0;
105SELECT @@session.sql_timeout;
106SET @@session.sql_timeout = -2;
107SELECT @@session.sql_timeout;
108--Error ER_WRONG_TYPE_FOR_VAR
109SET @@session.sql_timeout = 65530.34;
110SELECT @@session.sql_timeout;
111
112--Error ER_WRONG_TYPE_FOR_VAR
113SET @@session.sql_timeout = test;
114SELECT @@session.sql_timeout;
115
116
117--echo '#------------------FN_DYNVARS_083_06-----------------------#'
118####################################################################
119# Check if the value in GLOBAL Table matches value in variable #
120####################################################################
121
122
123SELECT @@global.sql_timeout = VARIABLE_VALUE
124FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
125WHERE VARIABLE_NAME='sql_timeout';
126
127--echo '#------------------FN_DYNVARS_083_07-----------------------#'
128####################################################################
129# Check if the value in SESSION Table matches value in variable #
130####################################################################
131
132SELECT @@session.sql_timeout = VARIABLE_VALUE
133FROM INFORMATION_SCHEMA.SESSION_VARIABLES
134WHERE VARIABLE_NAME='sql_timeout';
135
136
137--echo '#------------------FN_DYNVARS_083_08-----------------------#'
138####################################################################
139# Check if FALSE value can be used on variable #
140####################################################################
141
142SET @@global.sql_timeout = FALSE;
143SELECT @@global.sql_timeout;
144
145
146--echo '#---------------------FN_DYNVARS_083_09----------------------#'
147#############################################################################
148# Check if accessing variable with and without GLOBAL point #
149# to same variable #
150#############################################################################
151
152SET @@global.sql_timeout = 100;
153SELECT @@sql_timeout = @@global.sql_timeout;
154
155
156--echo '#---------------------FN_DYNVARS_083_10----------------------#'
157#############################################################################
158# Check if accessing variable with SESSION,LOCAL and without SCOPE points #
159# to same session variable #
160#############################################################################
161
162SET @@sql_timeout = 1000;
163SELECT @@sql_timeout = @@local.sql_timeout;
164SELECT @@local.sql_timeout = @@session.sql_timeout;
165
166
167--echo '#---------------------FN_DYNVARS_083_11----------------------#'
168############################################################################
169# Check if sql_timeout can be accessed with and without @@ sign #
170############################################################################
171
172SET sql_timeout = 100;
173SELECT @@sql_timeout;
174--Error ER_UNKNOWN_TABLE
175SELECT local.sql_timeout;
176--Error ER_UNKNOWN_TABLE
177SELECT session.sql_timeout;
178--Error ER_BAD_FIELD_ERROR
179SELECT sql_timeout = @@session.sql_timeout;
180
181
182####################################
183# Restore initial value #
184####################################
185
186SET @@global.sql_timeout = @start_global_value;
187SELECT @@global.sql_timeout;
188SET @@session.sql_timeout = @start_session_value;
189SELECT @@session.sql_timeout;
190
191
192#############################################################
193# END OF sql_timeout TESTS #
194#############################################################
0195
=== added file 'Percona-Server/mysql-test/t/percona_sql_timeout.test'
--- Percona-Server/mysql-test/t/percona_sql_timeout.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/percona_sql_timeout.test 2013-01-09 13:41:38 +0000
@@ -0,0 +1,82 @@
1#
2# SQL_TIMEOUT test
3#
4# SQL_TIMEOUT is a session variable or
5# query keyword which sets the time
6# limit for query execution.
7
8# Save the initial number of concurrent sessions
9--source include/count_sessions.inc
10
11
12--disable_query_log
13
14--let $sessions_count=10
15--let $sessions_prepared_count=10
16
17--let $i=$sessions_count
18while ($i) {
19--dec $i
20--let $connection_name=connection_$i
21--connect ($connection_name,localhost,root,,)
22--delimiter +++
23 let $statement=
24 SELECT SLEEP(1);
25 SET @@SESSION.SQL_TIMEOUT = 1;
26 SELECT SLEEP(1000);
27 SET @@SESSION.SQL_TIMEOUT = 0;
28 SELECT SLEEP(2);
29+++
30--delimiter ;
31--send_eval $statement
32}
33
34--let $i=$sessions_prepared_count
35while ($i) {
36--dec $i
37--let $ti=$sessions_count+$i
38--let $connection_name=connection_$ti
39--connect ($connection_name,localhost,root,,)
40--delimiter +++
41 let $statement=
42 PREPARE P_1_$i FROM 'SELECT SLEEP(1)';
43 PREPARE P_2_$i FROM 'SET @@SESSION.SQL_TIMEOUT = 1';
44 PREPARE P_3_$i FROM 'SELECT SLEEP(1000)';
45 PREPARE P_4_$i FROM 'SET @@SESSION.SQL_TIMEOUT = 0';
46 PREPARE P_5_$i FROM 'SELECT SLEEP(2)';
47 EXECUTE P_1_$i;
48 EXECUTE P_2_$i;
49 EXECUTE P_3_$i;
50 EXECUTE P_4_$i;
51 EXECUTE P_5_$i;
52+++
53--delimiter ;
54--send_eval $statement
55}
56
57--let $i=$sessions_count
58while ($i) {
59--dec $i
60--let $connection_name=connection_$i
61--connection $connection_name
62--reap
63--disconnect $connection_name
64}
65
66--let $i=$sessions_prepared_count
67while ($i) {
68--dec $i
69--let $ti=$sessions_count+$i
70--let $connection_name=connection_$ti
71--connection $connection_name
72--reap
73--eval DROP PREPARE P_1_$i
74--eval DROP PREPARE P_2_$i
75--eval DROP PREPARE P_3_$i
76--eval DROP PREPARE P_4_$i
77--eval DROP PREPARE P_5_$i
78--disconnect $connection_name
79}
80
81--connection default
82--source include/wait_until_count_sessions.inc
083
=== modified file 'Percona-Server/sql/binlog.cc'
--- Percona-Server/sql/binlog.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/binlog.cc 2013-01-09 13:41:38 +0000
@@ -1573,7 +1573,7 @@
1573 append_identifier(thd, &log_query, thd->lex->ident.str,1573 append_identifier(thd, &log_query, thd->lex->ident.str,
1574 thd->lex->ident.length);1574 thd->lex->ident.length);
15751575
1576 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);1576 int errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
1577 Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),1577 Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
1578 TRUE, FALSE, TRUE, errcode);1578 TRUE, FALSE, TRUE, errcode);
1579 /* 1579 /*
@@ -1615,7 +1615,7 @@
1615 log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||1615 log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
1616 log_query.append("`"))1616 log_query.append("`"))
1617 DBUG_RETURN(1);1617 DBUG_RETURN(1);
1618 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);1618 int errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
1619 Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),1619 Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
1620 TRUE, FALSE, TRUE, errcode);1620 TRUE, FALSE, TRUE, errcode);
1621 DBUG_RETURN(mysql_bin_log.write_event(&qinfo));1621 DBUG_RETURN(mysql_bin_log.write_event(&qinfo));
@@ -1930,7 +1930,7 @@
1930{1930{
1931 int error;1931 int error;
1932 1932
1933 if (not_killed || (thd->killed == THD::KILL_BAD_DATA))1933 if (not_killed || (thd->get_killed() == THD::KILL_BAD_DATA))
1934 {1934 {
1935 error= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0;1935 error= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0;
19361936
19371937
=== modified file 'Percona-Server/sql/debug_sync.cc'
--- Percona-Server/sql/debug_sync.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/sql/debug_sync.cc 2013-01-09 13:41:38 +0000
@@ -224,10 +224,10 @@
224 mysql_mutex_lock(&mutex);224 mysql_mutex_lock(&mutex);
225 thd->enter_cond(&condition_variable, &mutex, new_message);225 thd->enter_cond(&condition_variable, &mutex, new_message);
226 #if defined(ENABLE_DEBUG_SYNC)226 #if defined(ENABLE_DEBUG_SYNC)
227 if (!thd->killed && !end_of_wait_condition)227 if (!thd->get_killed() && !end_of_wait_condition)
228 DEBUG_SYNC(thd, "sync_point_name");228 DEBUG_SYNC(thd, "sync_point_name");
229 #endif229 #endif
230 while (!thd->killed && !end_of_wait_condition)230 while (!thd->get_killed() && !end_of_wait_condition)
231 mysql_cond_wait(&condition_variable, &mutex);231 mysql_cond_wait(&condition_variable, &mutex);
232 thd->exit_cond(old_message);232 thd->exit_cond(old_message);
233233
@@ -262,11 +262,11 @@
262 A bit off-topic: At some places, the loop is taken around the whole262 A bit off-topic: At some places, the loop is taken around the whole
263 synchronization pattern:263 synchronization pattern:
264264
265 while (!thd->killed && !end_of_wait_condition)265 while (!thd->get_killed() && !end_of_wait_condition)
266 {266 {
267 mysql_mutex_lock(&mutex);267 mysql_mutex_lock(&mutex);
268 thd->enter_cond(&condition_variable, &mutex, new_message);268 thd->enter_cond(&condition_variable, &mutex, new_message);
269 if (!thd->killed [&& !end_of_wait_condition])269 if (!thd->get_killed() [&& !end_of_wait_condition])
270 {270 {
271 [DEBUG_SYNC(thd, "sync_point_name");]271 [DEBUG_SYNC(thd, "sync_point_name");]
272 mysql_cond_wait(&condition_variable, &mutex);272 mysql_cond_wait(&condition_variable, &mutex);
@@ -274,9 +274,9 @@
274 thd->exit_cond(old_message);274 thd->exit_cond(old_message);
275 }275 }
276276
277 Note that it is important to repeat the test for thd->killed after277 Note that it is important to repeat the test for thd->get_killed() after
278 enter_cond(). Otherwise the killing thread may kill this thread after278 enter_cond(). Otherwise the killing thread may kill this thread after
279 it tested thd->killed in the loop condition and before it registered279 it tested thd->get_killed() in the loop condition and before it registered
280 the condition variable and mutex in enter_cond(). In this case, the280 the condition variable and mutex in enter_cond(). In this case, the
281 killing thread does not know that this thread is going to wait on a281 killing thread does not know that this thread is going to wait on a
282 condition variable. It would just set THD::killed. But if we would not282 condition variable. It would just set THD::killed. But if we would not
@@ -1123,13 +1123,13 @@
1123 point decremented it to 0. In this case the following happened:1123 point decremented it to 0. In this case the following happened:
11241124
1125 - an error message was reported with my_error() and1125 - an error message was reported with my_error() and
1126 - the statement was killed with thd->killed= THD::KILL_QUERY.1126 - the statement was killed with thd->get_killed()= THD::KILL_QUERY.
11271127
1128 If a statement reports an error, it must not call send_ok().1128 If a statement reports an error, it must not call send_ok().
1129 The calling functions will not call send_ok(), if we return TRUE1129 The calling functions will not call send_ok(), if we return TRUE
1130 from this function.1130 from this function.
11311131
1132 thd->killed is also set if the wait is interrupted from a1132 thd->get_killed() is also set if the wait is interrupted from a
1133 KILL or KILL QUERY statement. In this case, no error is reported1133 KILL or KILL QUERY statement. In this case, no error is reported
1134 and shall not be reported as a result of SET DEBUG_SYNC.1134 and shall not be reported as a result of SET DEBUG_SYNC.
1135 Hence, we check for the first condition above.1135 Hence, we check for the first condition above.
@@ -1775,7 +1775,7 @@
1775 the required dynamic memory allocated.1775 the required dynamic memory allocated.
1776 */1776 */
1777 while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for) &&1777 while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for) &&
1778 !thd->killed && opt_debug_sync_timeout)1778 !thd->get_killed() && opt_debug_sync_timeout)
1779 {1779 {
1780 error= mysql_cond_timedwait(&debug_sync_global.ds_cond,1780 error= mysql_cond_timedwait(&debug_sync_global.ds_cond,
1781 &debug_sync_global.ds_mutex,1781 &debug_sync_global.ds_mutex,
@@ -1800,10 +1800,10 @@
1800 error= 0;1800 error= 0;
1801 }1801 }
1802 DBUG_EXECUTE("debug_sync_exec",1802 DBUG_EXECUTE("debug_sync_exec",
1803 if (thd->killed)1803 if (thd->get_killed())
1804 DBUG_PRINT("debug_sync_exec",1804 DBUG_PRINT("debug_sync_exec",
1805 ("killed %d from '%s' at: '%s'",1805 ("killed %d from '%s' at: '%s'",
1806 thd->killed, sig_wait, dsp_name));1806 thd->get_killed(), sig_wait, dsp_name));
1807 else1807 else
1808 DBUG_PRINT("debug_sync_exec",1808 DBUG_PRINT("debug_sync_exec",
1809 ("%s from '%s' at: '%s'",1809 ("%s from '%s' at: '%s'",
@@ -1842,7 +1842,7 @@
1842 {1842 {
1843 if (!--action->hit_limit)1843 if (!--action->hit_limit)
1844 {1844 {
1845 thd->killed= THD::KILL_QUERY;1845 thd->set_killed(THD::KILL_QUERY);
1846 my_error(ER_DEBUG_SYNC_HIT_LIMIT, MYF(0));1846 my_error(ER_DEBUG_SYNC_HIT_LIMIT, MYF(0));
1847 }1847 }
1848 DBUG_PRINT("debug_sync_exec", ("hit_limit: %lu at: '%s'",1848 DBUG_PRINT("debug_sync_exec", ("hit_limit: %lu at: '%s'",
18491849
=== modified file 'Percona-Server/sql/event_queue.cc'
--- Percona-Server/sql/event_queue.cc 2011-09-07 10:08:09 +0000
+++ Percona-Server/sql/event_queue.cc 2013-01-09 13:41:38 +0000
@@ -575,9 +575,9 @@
575 Event_queue_element *top= NULL;575 Event_queue_element *top= NULL;
576576
577 /* Break loop if thd has been killed */577 /* Break loop if thd has been killed */
578 if (thd->killed)578 if (thd->get_killed())
579 {579 {
580 DBUG_PRINT("info", ("thd->killed=%d", thd->killed));580 DBUG_PRINT("info", ("thd->get_killed()=%d", thd->get_killed()));
581 goto end;581 goto end;
582 }582 }
583583
@@ -754,7 +754,7 @@
754754
755 thd->enter_cond(&COND_queue_state, &LOCK_event_queue, stage, NULL, src_func, src_file, src_line);755 thd->enter_cond(&COND_queue_state, &LOCK_event_queue, stage, NULL, src_func, src_file, src_line);
756756
757 if (!thd->killed)757 if (!thd->get_killed())
758 {758 {
759 if (!abstime)759 if (!abstime)
760 mysql_cond_wait(&COND_queue_state, &LOCK_event_queue);760 mysql_cond_wait(&COND_queue_state, &LOCK_event_queue);
761761
=== modified file 'Percona-Server/sql/event_scheduler.cc'
--- Percona-Server/sql/event_scheduler.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/sql/event_scheduler.cc 2013-01-09 13:41:38 +0000
@@ -495,7 +495,7 @@
495 }495 }
496 else496 else
497 {497 {
498 DBUG_ASSERT(thd->killed);498 DBUG_ASSERT(thd->get_killed());
499 DBUG_PRINT("info", ("job_data is NULL, the thread was killed"));499 DBUG_PRINT("info", ("job_data is NULL, the thread was killed"));
500 }500 }
501 DBUG_PRINT("info", ("state=%s", scheduler_states_names[state].str));501 DBUG_PRINT("info", ("state=%s", scheduler_states_names[state].str));
502502
=== modified file 'Percona-Server/sql/filesort.cc'
--- Percona-Server/sql/filesort.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/filesort.cc 2013-01-09 13:41:38 +0000
@@ -684,7 +684,6 @@
684 my_off_t record;684 my_off_t record;
685 TABLE *sort_form;685 TABLE *sort_form;
686 THD *thd= current_thd;686 THD *thd= current_thd;
687 volatile THD::killed_state *killed= &thd->killed;
688 handler *file;687 handler *file;
689 MY_BITMAP *save_read_set, *save_write_set;688 MY_BITMAP *save_read_set, *save_write_set;
690 bool skip_record;689 bool skip_record;
@@ -774,7 +773,7 @@
774 break;773 break;
775 }774 }
776775
777 if (*killed)776 if (thd->get_killed())
778 {777 {
779 DBUG_PRINT("info",("Sort killed by user"));778 DBUG_PRINT("info",("Sort killed by user"));
780 if (!quick_select)779 if (!quick_select)
@@ -1567,15 +1566,13 @@
1567 QUEUE queue;1566 QUEUE queue;
1568 qsort2_cmp cmp;1567 qsort2_cmp cmp;
1569 void *first_cmp_arg;1568 void *first_cmp_arg;
1570 volatile THD::killed_state *killed= &current_thd->killed;1569 THD::killed_state killed= current_thd->get_killed();
1571 THD::killed_state not_killable;
1572 DBUG_ENTER("merge_buffers");1570 DBUG_ENTER("merge_buffers");
15731571
1574 current_thd->inc_status_sort_merge_passes();1572 current_thd->inc_status_sort_merge_passes();
1575 if (param->not_killable)1573 if (param->not_killable)
1576 {1574 {
1577 killed= &not_killable;1575 killed= THD::NOT_KILLED;
1578 not_killable= THD::NOT_KILLED;
1579 }1576 }
15801577
1581 error=0;1578 error=0;
@@ -1646,7 +1643,7 @@
16461643
1647 while (queue.elements > 1)1644 while (queue.elements > 1)
1648 {1645 {
1649 if (*killed)1646 if (killed)
1650 {1647 {
1651 error= 1; goto err; /* purecov: inspected */1648 error= 1; goto err; /* purecov: inspected */
1652 }1649 }
16531650
=== modified file 'Percona-Server/sql/ha_ndbcluster.cc'
--- Percona-Server/sql/ha_ndbcluster.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/sql/ha_ndbcluster.cc 2013-01-09 13:41:38 +0000
@@ -4971,7 +4971,7 @@
4971 Ndb_tuple_id_range_guard g(m_share);4971 Ndb_tuple_id_range_guard g(m_share);
4972 if (ndb->getAutoIncrementValue(m_table, g.range, auto_value, 1000) == -1)4972 if (ndb->getAutoIncrementValue(m_table, g.range, auto_value, 1000) == -1)
4973 {4973 {
4974 if (--retries && !thd->killed &&4974 if (--retries && !thd->get_killed() &&
4975 ndb->getNdbError().status == NdbError::TemporaryError)4975 ndb->getNdbError().status == NdbError::TemporaryError)
4976 {4976 {
4977 do_retry_sleep(retry_sleep);4977 do_retry_sleep(retry_sleep);
@@ -8998,7 +8998,7 @@
8998 Ndb_tuple_id_range_guard g(m_share);8998 Ndb_tuple_id_range_guard g(m_share);
8999 if (ndb->readAutoIncrementValue(ndbtab, g.range, auto_value))8999 if (ndb->readAutoIncrementValue(ndbtab, g.range, auto_value))
9000 {9000 {
9001 if (--retries && !thd->killed &&9001 if (--retries && !thd->get_killed() &&
9002 ndb->getNdbError().status == NdbError::TemporaryError)9002 ndb->getNdbError().status == NdbError::TemporaryError)
9003 {9003 {
9004 do_retry_sleep(retry_sleep);9004 do_retry_sleep(retry_sleep);
@@ -9628,7 +9628,7 @@
9628 Failed to create an index,9628 Failed to create an index,
9629 drop the table (and all it's indexes)9629 drop the table (and all it's indexes)
9630 */9630 */
9631 while (!thd->killed)9631 while (!thd->get_killed())
9632 {9632 {
9633 if (dict->beginSchemaTrans() == -1)9633 if (dict->beginSchemaTrans() == -1)
9634 goto cleanup_failed;9634 goto cleanup_failed;
@@ -9637,7 +9637,7 @@
9637 switch (dict->getNdbError().status)9637 switch (dict->getNdbError().status)
9638 {9638 {
9639 case NdbError::TemporaryError:9639 case NdbError::TemporaryError:
9640 if (!thd->killed) 9640 if (!thd->get_killed())
9641 {9641 {
9642 if (dict->endSchemaTrans(NdbDictionary::Dictionary::SchemaTransAbort)9642 if (dict->endSchemaTrans(NdbDictionary::Dictionary::SchemaTransAbort)
9643 == -1)9643 == -1)
@@ -10238,7 +10238,7 @@
10238 switch (dict->getNdbError().status)10238 switch (dict->getNdbError().status)
10239 {10239 {
10240 case NdbError::TemporaryError:10240 case NdbError::TemporaryError:
10241 if (!thd->killed) 10241 if (!thd->get_killed())
10242 goto retry_temporary_error1; // retry indefinitly10242 goto retry_temporary_error1; // retry indefinitly
10243 break;10243 break;
10244 default:10244 default:
@@ -10270,7 +10270,7 @@
10270 switch (dict->getNdbError().status)10270 switch (dict->getNdbError().status)
10271 {10271 {
10272 case NdbError::TemporaryError:10272 case NdbError::TemporaryError:
10273 if (!thd->killed) 10273 if (!thd->get_killed())
10274 goto retry_temporary_error2; // retry indefinitly10274 goto retry_temporary_error2; // retry indefinitly
10275 break;10275 break;
10276 default:10276 default:
@@ -10426,7 +10426,7 @@
10426 Uint32(m_autoincrement_prefetch), 10426 Uint32(m_autoincrement_prefetch),
10427 increment, offset))10427 increment, offset))
10428 {10428 {
10429 if (--retries && !thd->killed &&10429 if (--retries && !thd->get_killed() &&
10430 ndb->getNdbError().status == NdbError::TemporaryError)10430 ndb->getNdbError().status == NdbError::TemporaryError)
10431 {10431 {
10432 do_retry_sleep(retry_sleep);10432 do_retry_sleep(retry_sleep);
@@ -10734,7 +10734,7 @@
10734 }10734 }
10735 while((result= th.next()) == 1)10735 while((result= th.next()) == 1)
10736 {10736 {
10737 if (thd->killed)10737 if (thd->get_killed())
10738 DBUG_RETURN(-1);10738 DBUG_RETURN(-1);
10739 my_sleep(1000*delay);10739 my_sleep(1000*delay);
10740 }10740 }
@@ -10746,7 +10746,7 @@
10746 };10746 };
10747 for (i= 0; i < MAX_KEY; i++)10747 for (i= 0; i < MAX_KEY; i++)
10748 {10748 {
10749 if (thd->killed)10749 if (thd->get_killed())
10750 DBUG_RETURN(-1);10750 DBUG_RETURN(-1);
10751 if (m_index[i].status == ACTIVE)10751 if (m_index[i].status == ACTIVE)
10752 {10752 {
@@ -10765,7 +10765,7 @@
10765 }10765 }
10766 while((result= ih.next()) == 1)10766 while((result= ih.next()) == 1)
10767 {10767 {
10768 if (thd->killed)10768 if (thd->get_killed())
10769 DBUG_RETURN(-1);10769 DBUG_RETURN(-1);
10770 my_sleep(1000*delay); 10770 my_sleep(1000*delay);
10771 }10771 }
@@ -10787,7 +10787,7 @@
10787 } 10787 }
10788 while((result= ih.next()) == 1)10788 while((result= ih.next()) == 1)
10789 {10789 {
10790 if (thd->killed)10790 if (thd->get_killed())
10791 DBUG_RETURN(-1);10791 DBUG_RETURN(-1);
10792 my_sleep(1000*delay);10792 my_sleep(1000*delay);
10793 }10793 }
@@ -13451,7 +13451,7 @@
13451 pTrans= NULL;13451 pTrans= NULL;
13452 }13452 }
13453 if (error.status == NdbError::TemporaryError &&13453 if (error.status == NdbError::TemporaryError &&
13454 retries-- && !thd->killed)13454 retries-- && !thd->get_killed())
13455 {13455 {
13456 do_retry_sleep(retry_sleep);13456 do_retry_sleep(retry_sleep);
13457 continue;13457 continue;
1345813458
=== modified file 'Percona-Server/sql/ha_ndbcluster_binlog.cc'
--- Percona-Server/sql/ha_ndbcluster_binlog.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/ha_ndbcluster_binlog.cc 2013-01-09 13:41:38 +0000
@@ -485,7 +485,7 @@
485 thd->proc_info= "Waiting for ndbcluster binlog update to "485 thd->proc_info= "Waiting for ndbcluster binlog update to "
486 "reach current position";486 "reach current position";
487 pthread_mutex_lock(&injector_mutex);487 pthread_mutex_lock(&injector_mutex);
488 while (!(thd && thd->killed) && count && ndb_binlog_running &&488 while (!(thd && thd->get_killed()) && count && ndb_binlog_running &&
489 (ndb_latest_handled_binlog_epoch == 0 ||489 (ndb_latest_handled_binlog_epoch == 0 ||
490 ndb_latest_handled_binlog_epoch < wait_epoch))490 ndb_latest_handled_binlog_epoch < wait_epoch))
491 {491 {
@@ -1291,7 +1291,7 @@
1291 ndb->closeTransaction(trans);1291 ndb->closeTransaction(trans);
1292 trans= NULL;1292 trans= NULL;
1293 }1293 }
1294 if (ndb_error.status == NdbError::TemporaryError && !thd->killed)1294 if (ndb_error.status == NdbError::TemporaryError && !thd->get_killed())
1295 {1295 {
1296 if (retries--)1296 if (retries--)
1297 {1297 {
@@ -1302,7 +1302,7 @@
1302 continue; // retry1302 continue; // retry
1303 }1303 }
1304 }1304 }
1305 if (!thd->killed)1305 if (!thd->get_killed())
1306 {1306 {
1307 sql_print_error("NDB: ndbcluster_find_all_databases fail: %u - %s",1307 sql_print_error("NDB: ndbcluster_find_all_databases fail: %u - %s",
1308 ndb_error.code,1308 ndb_error.code,
@@ -1663,7 +1663,7 @@
1663 err:1663 err:
1664 const NdbError *this_error= trans ?1664 const NdbError *this_error= trans ?
1665 &trans->getNdbError() : &ndb->getNdbError();1665 &trans->getNdbError() : &ndb->getNdbError();
1666 if (this_error->status == NdbError::TemporaryError && !thd->killed)1666 if (this_error->status == NdbError::TemporaryError && !thd->get_killed())
1667 {1667 {
1668 if (retries--)1668 if (retries--)
1669 {1669 {
@@ -2128,7 +2128,7 @@
2128err:2128err:
2129 const NdbError *this_error= trans ?2129 const NdbError *this_error= trans ?
2130 &trans->getNdbError() : &ndb->getNdbError();2130 &trans->getNdbError() : &ndb->getNdbError();
2131 if (this_error->status == NdbError::TemporaryError && !thd->killed)2131 if (this_error->status == NdbError::TemporaryError && !thd->get_killed())
2132 {2132 {
2133 if (retries--)2133 if (retries--)
2134 {2134 {
@@ -2183,7 +2183,7 @@
2183 int ret= pthread_cond_timedwait(&injector_cond,2183 int ret= pthread_cond_timedwait(&injector_cond,
2184 &ndb_schema_object->mutex,2184 &ndb_schema_object->mutex,
2185 &abstime);2185 &abstime);
2186 if (thd->killed)2186 if (thd->get_killed())
2187 break;2187 break;
21882188
2189 /* begin protect ndb_schema_share */2189 /* begin protect ndb_schema_share */
@@ -2424,7 +2424,7 @@
2424 char *thd_db_save= thd->db;2424 char *thd_db_save= thd->db;
2425 thd->server_id = loggedServerId;2425 thd->server_id = loggedServerId;
2426 thd->db= schema->db;2426 thd->db= schema->db;
2427 int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED);2427 int errcode = query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
2428 thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query,2428 thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query,
2429 schema->query_length, FALSE,2429 schema->query_length, FALSE,
2430#ifdef NDB_THD_BINLOG_QUERY_HAS_DIRECT2430#ifdef NDB_THD_BINLOG_QUERY_HAS_DIRECT
@@ -3253,7 +3253,7 @@
3253 MYSQL_LOCK_IGNORE_TIMEOUT; /* Wait for lock "infinitely" */3253 MYSQL_LOCK_IGNORE_TIMEOUT; /* Wait for lock "infinitely" */
3254 if (open_and_lock_tables(thd, &tables, derived, flags))3254 if (open_and_lock_tables(thd, &tables, derived, flags))
3255 {3255 {
3256 if (thd->killed)3256 if (thd->get_killed())
3257 sql_print_error("NDB Binlog: Opening ndb_binlog_index: killed");3257 sql_print_error("NDB Binlog: Opening ndb_binlog_index: killed");
3258 else3258 else
3259 sql_print_error("NDB Binlog: Opening ndb_binlog_index: %d, '%s'",3259 sql_print_error("NDB Binlog: Opening ndb_binlog_index: %d, '%s'",
@@ -5392,7 +5392,7 @@
5392 share->event_data= event_data;5392 share->event_data= event_data;
5393 op->setCustomData(NULL);5393 op->setCustomData(NULL);
5394 ndb->dropEventOperation(op);5394 ndb->dropEventOperation(op);
5395 if (retries && !thd->killed)5395 if (retries && !thd->get_killed())
5396 {5396 {
5397 do_retry_sleep(retry_sleep);5397 do_retry_sleep(retry_sleep);
5398 continue;5398 continue;
@@ -5530,7 +5530,7 @@
5530 int ret= pthread_cond_timedwait(&injector_cond,5530 int ret= pthread_cond_timedwait(&injector_cond,
5531 &share->mutex,5531 &share->mutex,
5532 &abstime);5532 &abstime);
5533 if (thd->killed ||5533 if (thd->get_killed() ||
5534 share->op == 0)5534 share->op == 0)
5535 break;5535 break;
5536 if (ret)5536 if (ret)
@@ -7206,15 +7206,15 @@
7206 Writing to ndb_binlog_index failed, check if we are7206 Writing to ndb_binlog_index failed, check if we are
7207 being killed and retry7207 being killed and retry
7208 */7208 */
7209 if (thd->killed)7209 if (thd->get_killed())
7210 {7210 {
7211 (void) mysql_mutex_lock(&LOCK_thread_count);7211 (void) mysql_mutex_lock(&LOCK_thread_count);
7212 volatile THD::killed_state killed= thd->killed;7212 volatile THD::killed_state killed= thd->get_killed();
7213 /* We are cleaning up, allow for flushing last epoch */7213 /* We are cleaning up, allow for flushing last epoch */
7214 thd->killed= THD::NOT_KILLED;7214 thd->set_killed(THD::NOT_KILLED);
7215 ndb_binlog_index_table__write_rows(thd, rows);7215 ndb_binlog_index_table__write_rows(thd, rows);
7216 /* Restore kill flag */7216 /* Restore kill flag */
7217 thd->killed= killed;7217 thd->set_killed(killed);
7218 (void) mysql_mutex_unlock(&LOCK_thread_count);7218 (void) mysql_mutex_unlock(&LOCK_thread_count);
7219 }7219 }
7220 }7220 }
72217221
=== modified file 'Percona-Server/sql/handler.cc'
--- Percona-Server/sql/handler.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/handler.cc 2013-01-09 13:41:38 +0000
@@ -1603,7 +1603,7 @@
1603#endif1603#endif
1604 if ((all || thd->transaction.stmt.ha_list == 0) &&1604 if ((all || thd->transaction.stmt.ha_list == 0) &&
1605 thd->transaction.all.cannot_safely_rollback() &&1605 thd->transaction.all.cannot_safely_rollback() &&
1606 !thd->slave_thread && thd->killed != THD::KILL_CONNECTION)1606 !thd->slave_thread && thd->get_killed() != THD::KILL_CONNECTION)
1607 thd->transaction.push_unsafe_rollback_warnings(thd);1607 thd->transaction.push_unsafe_rollback_warnings(thd);
1608 DBUG_RETURN(error);1608 DBUG_RETURN(error);
1609}1609}
@@ -3210,7 +3210,7 @@
3210 /*3210 /*
3211 first test if the query was aborted due to strict mode constraints3211 first test if the query was aborted due to strict mode constraints
3212 */3212 */
3213 if (thd->killed == THD::KILL_BAD_DATA)3213 if (thd->get_killed() == THD::KILL_BAD_DATA)
3214 DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);3214 DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
32153215
3216 /*3216 /*
@@ -5452,7 +5452,7 @@
54525452
5453 @note5453 @note
5454 This method (or an overriding one in a derived class) must check for5454 This method (or an overriding one in a derived class) must check for
5455 thd->killed and return HA_POS_ERROR if it is not zero. This is required5455 thd->get_killed() and return HA_POS_ERROR if it is not zero. This is required
5456 for a user to be able to interrupt the calculation by killing the5456 for a user to be able to interrupt the calculation by killing the
5457 connection/query.5457 connection/query.
54585458
@@ -5479,12 +5479,12 @@
5479 /* Default MRR implementation doesn't need buffer */5479 /* Default MRR implementation doesn't need buffer */
5480 *bufsz= 0;5480 *bufsz= 0;
54815481
5482 DBUG_EXECUTE_IF("bug13822652_2", thd->killed= THD::KILL_QUERY;);5482 DBUG_EXECUTE_IF("bug13822652_2", thd->set_killed(THD::KILL_QUERY););
54835483
5484 seq_it= seq->init(seq_init_param, n_ranges, *flags);5484 seq_it= seq->init(seq_init_param, n_ranges, *flags);
5485 while (!seq->next(seq_it, &range))5485 while (!seq->next(seq_it, &range))
5486 {5486 {
5487 if (unlikely(thd->killed != 0))5487 if (unlikely(thd->get_killed() != 0))
5488 return HA_POS_ERROR;5488 return HA_POS_ERROR;
5489 5489
5490 n_ranges++;5490 n_ranges++;
54915491
=== modified file 'Percona-Server/sql/item_func.cc'
--- Percona-Server/sql/item_func.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/item_func.cc 2013-01-09 13:41:38 +0000
@@ -4215,6 +4215,11 @@
4215 error= mysql_cond_timedwait(cond, mutex, &timeout);4215 error= mysql_cond_timedwait(cond, mutex, &timeout);
4216 if (error == ETIMEDOUT || error == ETIME)4216 if (error == ETIMEDOUT || error == ETIME)
4217 {4217 {
4218 if (m_thd->get_killed())
4219 {
4220 error= 0;
4221 break;
4222 }
4218 /* Return error if timed out or connection is broken. */4223 /* Return error if timed out or connection is broken. */
4219 if (!cmp_timespec(timeout, m_abs_timeout) || !m_thd->is_connected())4224 if (!cmp_timespec(timeout, m_abs_timeout) || !m_thd->is_connected())
4220 break;4225 break;
@@ -4312,7 +4317,7 @@
43124317
4313 error= 0;4318 error= 0;
4314 thd_wait_begin(thd, THD_WAIT_USER_LOCK);4319 thd_wait_begin(thd, THD_WAIT_USER_LOCK);
4315 while (ull->locked && !thd->killed)4320 while (ull->locked && !thd->get_killed())
4316 {4321 {
4317 DBUG_PRINT("info", ("waiting on lock"));4322 DBUG_PRINT("info", ("waiting on lock"));
4318 error= timed_cond.wait(&ull->cond, &LOCK_user_locks);4323 error= timed_cond.wait(&ull->cond, &LOCK_user_locks);
@@ -4332,7 +4337,7 @@
4332 DBUG_ASSERT(0);4337 DBUG_ASSERT(0);
4333 delete ull; // Should never happen4338 delete ull; // Should never happen
4334 }4339 }
4335 if (!error) // Killed (thd->killed != 0)4340 if (!error) // Killed (thd->get_killed() != 0)
4336 {4341 {
4337 error=1;4342 error=1;
4338 null_value=1; // Return NULL4343 null_value=1; // Return NULL
@@ -4469,7 +4474,7 @@
4469 }4474 }
44704475
4471 null_value=0;4476 null_value=0;
4472 for (ulonglong loop=0 ; loop < loop_count && !thd->killed; loop++)4477 for (ulonglong loop=0 ; loop < loop_count && !thd->get_killed(); loop++)
4473 {4478 {
4474 switch (args[1]->result_type()) {4479 switch (args[1]->result_type()) {
4475 case REAL_RESULT:4480 case REAL_RESULT:
@@ -4541,7 +4546,7 @@
45414546
4542 error= 0;4547 error= 0;
4543 thd_wait_begin(thd, THD_WAIT_SLEEP);4548 thd_wait_begin(thd, THD_WAIT_SLEEP);
4544 while (!thd->killed)4549 while (!thd->get_killed())
4545 {4550 {
4546 error= timed_cond.wait(&cond, &LOCK_user_locks);4551 error= timed_cond.wait(&cond, &LOCK_user_locks);
4547 if (error == ETIMEDOUT || error == ETIME)4552 if (error == ETIMEDOUT || error == ETIME)
@@ -6742,7 +6747,7 @@
6742 {6747 {
6743 null_value= 1;6748 null_value= 1;
6744 context->process_error(thd);6749 context->process_error(thd);
6745 if (thd->killed)6750 if (thd->get_killed())
6746 thd->send_kill_message();6751 thd->send_kill_message();
6747 return TRUE;6752 return TRUE;
6748 }6753 }
67496754
=== modified file 'Percona-Server/sql/item_subselect.cc'
--- Percona-Server/sql/item_subselect.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/item_subselect.cc 2013-01-09 13:41:38 +0000
@@ -572,7 +572,7 @@
572 or if the query has been killed.572 or if the query has been killed.
573 */573 */
574 THD * const thd= unit->thd;574 THD * const thd= unit->thd;
575 if (thd->is_error() || thd->killed)575 if (thd->is_error() || thd->get_killed())
576 DBUG_RETURN(true);576 DBUG_RETURN(true);
577577
578 DBUG_ASSERT(!thd->lex->context_analysis_only);578 DBUG_ASSERT(!thd->lex->context_analysis_only);
579579
=== modified file 'Percona-Server/sql/lock.cc'
--- Percona-Server/sql/lock.cc 2012-03-06 14:29:42 +0000
+++ Percona-Server/sql/lock.cc 2013-01-09 13:41:38 +0000
@@ -324,11 +324,11 @@
324 if (sql_lock->table_count)324 if (sql_lock->table_count)
325 (void) unlock_external(thd, sql_lock->table, sql_lock->table_count);325 (void) unlock_external(thd, sql_lock->table, sql_lock->table_count);
326 reset_lock_data_and_free(&sql_lock);326 reset_lock_data_and_free(&sql_lock);
327 if (! thd->killed)327 if (! thd->get_killed())
328 my_error(rc, MYF(0));328 my_error(rc, MYF(0));
329 }329 }
330end:330end:
331 if (thd->killed)331 if (thd->get_killed())
332 {332 {
333 thd->send_kill_message();333 thd->send_kill_message();
334 if (sql_lock)334 if (sql_lock)
335335
=== modified file 'Percona-Server/sql/log.cc'
--- Percona-Server/sql/log.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/log.cc 2013-01-09 13:41:38 +0000
@@ -501,7 +501,7 @@
501 result= FALSE;501 result= FALSE;
502502
503err:503err:
504 if (result && !thd->killed)504 if (result && !thd->get_killed())
505 sql_print_error("Failed to write to mysql.general_log: %s",505 sql_print_error("Failed to write to mysql.general_log: %s",
506 error_handler.message());506 error_handler.message());
507507
@@ -699,7 +699,7 @@
699err:699err:
700 thd->pop_internal_handler();700 thd->pop_internal_handler();
701701
702 if (result && !thd->killed)702 if (result && !thd->get_killed())
703 sql_print_error("Failed to write to mysql.slow_log: %s",703 sql_print_error("Failed to write to mysql.slow_log: %s",
704 error_handler.message());704 error_handler.message());
705705
706706
=== modified file 'Percona-Server/sql/log_event.cc'
--- Percona-Server/sql/log_event.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/log_event.cc 2013-01-09 13:41:38 +0000
@@ -4799,7 +4799,7 @@
4799 get_type_str(), thd->get_stmt_da()->message());4799 get_type_str(), thd->get_stmt_da()->message());
4800 }4800 }
4801 clear_all_errors(thd, const_cast<Relay_log_info*>(rli));4801 clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
4802 thd->killed= THD::NOT_KILLED;4802 thd->set_killed(THD::NOT_KILLED);
4803 }4803 }
4804 /*4804 /*
4805 Other cases: mostly we expected no error and get one.4805 Other cases: mostly we expected no error and get one.
48064806
=== modified file 'Percona-Server/sql/mysqld.cc'
--- Percona-Server/sql/mysqld.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/mysqld.cc 2013-01-09 13:41:38 +0000
@@ -1376,7 +1376,7 @@
1376 if (tmp->slave_thread)1376 if (tmp->slave_thread)
1377 continue;1377 continue;
13781378
1379 tmp->killed= THD::KILL_CONNECTION;1379 tmp->set_killed(THD::KILL_CONNECTION);
1380 MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp));1380 MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp));
1381 mysql_mutex_lock(&tmp->LOCK_thd_data);1381 mysql_mutex_lock(&tmp->LOCK_thd_data);
1382 if (tmp->mysys_var)1382 if (tmp->mysys_var)
@@ -5933,7 +5933,7 @@
5933 DBUG_PRINT("error",5933 DBUG_PRINT("error",
5934 ("Can't create thread to handle request (error %d)",5934 ("Can't create thread to handle request (error %d)",
5935 error));5935 error));
5936 thd->killed= THD::KILL_CONNECTION; // Safety5936 thd->set_killed(THD::KILL_CONNECTION); // Safety
5937 mysql_mutex_unlock(&LOCK_thread_count);5937 mysql_mutex_unlock(&LOCK_thread_count);
59385938
5939 mysql_mutex_lock(&LOCK_connection_count);5939 mysql_mutex_lock(&LOCK_connection_count);
59405940
=== modified file 'Percona-Server/sql/opt_range.cc'
--- Percona-Server/sql/opt_range.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/opt_range.cc 2013-01-09 13:41:38 +0000
@@ -9866,7 +9866,7 @@
9866 break;9866 break;
9867 }9867 }
98689868
9869 if (thd->killed)9869 if (thd->get_killed())
9870 DBUG_RETURN(1);9870 DBUG_RETURN(1);
98719871
9872 /* skip row if it will be retrieved by clustered PK scan */9872 /* skip row if it will be retrieved by clustered PK scan */
98739873
=== modified file 'Percona-Server/sql/records.cc'
--- Percona-Server/sql/records.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/records.cc 2013-01-09 13:41:38 +0000
@@ -340,7 +340,7 @@
340340
341static int rr_handle_error(READ_RECORD *info, int error)341static int rr_handle_error(READ_RECORD *info, int error)
342{342{
343 if (info->thd->killed)343 if (info->thd->get_killed())
344 {344 {
345 info->thd->send_kill_message();345 info->thd->send_kill_message();
346 return 1;346 return 1;
@@ -366,7 +366,7 @@
366 int tmp;366 int tmp;
367 while ((tmp= info->select->quick->get_next()))367 while ((tmp= info->select->quick->get_next()))
368 {368 {
369 if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED))369 if (info->thd->get_killed() || (tmp != HA_ERR_RECORD_DELETED))
370 {370 {
371 tmp= rr_handle_error(info, tmp);371 tmp= rr_handle_error(info, tmp);
372 break;372 break;
@@ -481,7 +481,7 @@
481 ha_rnd_next can return RECORD_DELETED for MyISAM when one thread is481 ha_rnd_next can return RECORD_DELETED for MyISAM when one thread is
482 reading and another deleting without locks.482 reading and another deleting without locks.
483 */483 */
484 if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED))484 if (info->thd->get_killed() || (tmp != HA_ERR_RECORD_DELETED))
485 {485 {
486 tmp= rr_handle_error(info, tmp);486 tmp= rr_handle_error(info, tmp);
487 break;487 break;
488488
=== modified file 'Percona-Server/sql/rpl_gtid_execution.cc'
--- Percona-Server/sql/rpl_gtid_execution.cc 2012-09-17 18:49:38 +0000
+++ Percona-Server/sql/rpl_gtid_execution.cc 2013-01-09 13:41:38 +0000
@@ -78,7 +78,7 @@
78 // global_sid_lock and mutex are now released78 // global_sid_lock and mutex are now released
7979
80 // Check if thread was killed.80 // Check if thread was killed.
81 if (thd->killed || abort_loop)81 if (thd->get_killed() || abort_loop)
82 DBUG_RETURN(1);82 DBUG_RETURN(1);
83#ifdef HAVE_REPLICATION83#ifdef HAVE_REPLICATION
84 // If this thread is a slave SQL thread or slave SQL worker84 // If this thread is a slave SQL thread or slave SQL worker
@@ -159,7 +159,7 @@
159159
160 // at this point, we don't hold any locks. re-acquire the global160 // at this point, we don't hold any locks. re-acquire the global
161 // read lock that was held when this function was invoked161 // read lock that was held when this function was invoked
162 if (thd->killed || abort_loop)162 if (thd->get_killed() || abort_loop)
163 DBUG_RETURN(1);163 DBUG_RETURN(1);
164#ifdef HAVE_REPLICATION164#ifdef HAVE_REPLICATION
165 // If this thread is a slave SQL thread or slave SQL worker165 // If this thread is a slave SQL thread or slave SQL worker
166166
=== modified file 'Percona-Server/sql/rpl_gtid_state.cc'
--- Percona-Server/sql/rpl_gtid_state.cc 2012-09-17 18:49:38 +0000
+++ Percona-Server/sql/rpl_gtid_state.cc 2013-01-09 13:41:38 +0000
@@ -262,7 +262,7 @@
262 sid_locks.enter_cond(thd, gtid.sidno,262 sid_locks.enter_cond(thd, gtid.sidno,
263 &stage_waiting_for_gtid_to_be_written_to_binary_log,263 &stage_waiting_for_gtid_to_be_written_to_binary_log,
264 &old_stage);264 &old_stage);
265 //while (get_owner(g.sidno, g.gno) != 0 && !thd->killed && !abort_loop)265 //while (get_owner(g.sidno, g.gno) != 0 && !thd->get_killed() && !abort_loop)
266 sid_locks.wait(gtid.sidno);266 sid_locks.wait(gtid.sidno);
267 thd->EXIT_COND(&old_stage);267 thd->EXIT_COND(&old_stage);
268268
269269
=== modified file 'Percona-Server/sql/rpl_master.cc'
--- Percona-Server/sql/rpl_master.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/sql/rpl_master.cc 2013-01-09 13:41:38 +0000
@@ -1090,7 +1090,7 @@
1090 /* seek to the requested position, to start the requested dump */1090 /* seek to the requested position, to start the requested dump */
1091 my_b_seek(&log, pos); // Seek will done on next read1091 my_b_seek(&log, pos); // Seek will done on next read
10921092
1093 while (!net->error && net->vio != 0 && !thd->killed)1093 while (!net->error && net->vio != 0 && !thd->get_killed())
1094 {1094 {
1095 Log_event_type event_type= UNKNOWN_EVENT;1095 Log_event_type event_type= UNKNOWN_EVENT;
10961096
@@ -1430,7 +1430,7 @@
1430 {1430 {
1431 DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));1431 DBUG_PRINT("wait",("binary log received update or a broadcast signal caught"));
1432 }1432 }
1433 } while (signal_cnt == mysql_bin_log.signal_cnt && !thd->killed);1433 } while (signal_cnt == mysql_bin_log.signal_cnt && !thd->get_killed());
1434 thd->EXIT_COND(&old_stage);1434 thd->EXIT_COND(&old_stage);
1435 }1435 }
1436 break;1436 break;
14371437
=== modified file 'Percona-Server/sql/rpl_rli.cc'
--- Percona-Server/sql/rpl_rli.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/rpl_rli.cc 2013-01-09 13:41:38 +0000
@@ -675,7 +675,7 @@
675 }675 }
676676
677 /* The "compare and wait" main loop */677 /* The "compare and wait" main loop */
678 while (!thd->killed &&678 while (!thd->get_killed() &&
679 init_abort_pos_wait == abort_pos_wait &&679 init_abort_pos_wait == abort_pos_wait &&
680 slave_running)680 slave_running)
681 {681 {
@@ -727,7 +727,7 @@
727727
728 pos_reached= ((!cmp_result && group_master_log_pos >= (ulonglong)log_pos) ||728 pos_reached= ((!cmp_result && group_master_log_pos >= (ulonglong)log_pos) ||
729 cmp_result > 0);729 cmp_result > 0);
730 if (pos_reached || thd->killed)730 if (pos_reached || thd->get_killed())
731 break;731 break;
732 }732 }
733733
@@ -785,7 +785,7 @@
785 (int) slave_running,785 (int) slave_running,
786 (int) (error == -2),786 (int) (error == -2),
787 (int) (error == -1)));787 (int) (error == -1)));
788 if (thd->killed || init_abort_pos_wait != abort_pos_wait ||788 if (thd->get_killed() || init_abort_pos_wait != abort_pos_wait ||
789 !slave_running)789 !slave_running)
790 {790 {
791 error= -2;791 error= -2;
@@ -845,7 +845,7 @@
845 global_sid_lock->unlock();845 global_sid_lock->unlock();
846846
847 /* The "compare and wait" main loop */847 /* The "compare and wait" main loop */
848 while (!thd->killed &&848 while (!thd->get_killed() &&
849 init_abort_pos_wait == abort_pos_wait &&849 init_abort_pos_wait == abort_pos_wait &&
850 slave_running)850 slave_running)
851 {851 {
@@ -931,7 +931,7 @@
931 (int) slave_running,931 (int) slave_running,
932 (int) (error == -2),932 (int) (error == -2),
933 (int) (error == -1)));933 (int) (error == -1)));
934 if (thd->killed || init_abort_pos_wait != abort_pos_wait ||934 if (thd->get_killed() || init_abort_pos_wait != abort_pos_wait ||
935 !slave_running)935 !slave_running)
936 {936 {
937 error= -2;937 error= -2;
938938
=== modified file 'Percona-Server/sql/rpl_rli_pdb.cc'
--- Percona-Server/sql/rpl_rli_pdb.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/rpl_rli_pdb.cc 2013-01-09 13:41:38 +0000
@@ -887,10 +887,10 @@
887 &stage_slave_waiting_worker_to_release_partition,887 &stage_slave_waiting_worker_to_release_partition,
888 &old_stage);888 &old_stage);
889 mysql_cond_wait(&slave_worker_hash_cond, &slave_worker_hash_lock);889 mysql_cond_wait(&slave_worker_hash_cond, &slave_worker_hash_lock);
890 } while (entry->usage != 0 && !thd->killed);890 } while (entry->usage != 0 && !thd->get_killed());
891891
892 thd->EXIT_COND(&old_stage);892 thd->EXIT_COND(&old_stage);
893 if (thd->killed)893 if (thd->get_killed())
894 {894 {
895 entry= NULL;895 entry= NULL;
896 goto err;896 goto err;
@@ -1500,7 +1500,7 @@
1500 continue;1500 continue;
1501 }1501 }
15021502
1503 if (entry->usage > 0 && !thd->killed)1503 if (entry->usage > 0 && !thd->get_killed())
1504 {1504 {
1505 PSI_stage_info old_stage;1505 PSI_stage_info old_stage;
1506 Slave_worker *w_entry= entry->worker;1506 Slave_worker *w_entry= entry->worker;
@@ -1517,7 +1517,7 @@
1517 ("Either got awakened of notified: "1517 ("Either got awakened of notified: "
1518 "entry %p, usage %lu, worker %lu",1518 "entry %p, usage %lu, worker %lu",
1519 entry, entry->usage, w_entry->id));1519 entry, entry->usage, w_entry->id));
1520 } while (entry->usage != 0 && !thd->killed);1520 } while (entry->usage != 0 && !thd->get_killed());
1521 entry->worker= w_entry; // restoring last association, needed only for assert1521 entry->worker= w_entry; // restoring last association, needed only for assert
1522 thd->EXIT_COND(&old_stage);1522 thd->EXIT_COND(&old_stage);
1523 ret++;1523 ret++;
@@ -1659,7 +1659,7 @@
1659 &stage_slave_waiting_worker_to_free_events, &old_stage);1659 &stage_slave_waiting_worker_to_free_events, &old_stage);
1660 mysql_cond_wait(&rli->pending_jobs_cond, &rli->pending_jobs_lock);1660 mysql_cond_wait(&rli->pending_jobs_cond, &rli->pending_jobs_lock);
1661 thd->EXIT_COND(&old_stage);1661 thd->EXIT_COND(&old_stage);
1662 if (thd->killed)1662 if (thd->get_killed())
1663 return true;1663 return true;
1664 if (log_warnings > 1 && (rli->wq_size_waits_cnt % 10 == 1))1664 if (log_warnings > 1 && (rli->wq_size_waits_cnt % 10 == 1))
1665 sql_print_information("Multi-threaded slave: Coordinator has waited "1665 sql_print_information("Multi-threaded slave: Coordinator has waited "
@@ -1701,7 +1701,7 @@
1701 mysql_mutex_lock(&worker->jobs_lock);1701 mysql_mutex_lock(&worker->jobs_lock);
17021702
1703 // possible WQ overfill1703 // possible WQ overfill
1704 while (worker->running_status == Slave_worker::RUNNING && !thd->killed &&1704 while (worker->running_status == Slave_worker::RUNNING && !thd->get_killed() &&
1705 (ret= en_queue(&worker->jobs, job_item)) == -1)1705 (ret= en_queue(&worker->jobs, job_item)) == -1)
1706 {1706 {
1707 thd->ENTER_COND(&worker->jobs_cond, &worker->jobs_lock, 1707 thd->ENTER_COND(&worker->jobs_cond, &worker->jobs_lock,
@@ -1752,7 +1752,7 @@
17521752
1753 mysql_mutex_lock(&worker->jobs_lock);1753 mysql_mutex_lock(&worker->jobs_lock);
17541754
1755 while (!job_item->data && !thd->killed &&1755 while (!job_item->data && !thd->get_killed() &&
1756 worker->running_status == Slave_worker::RUNNING)1756 worker->running_status == Slave_worker::RUNNING)
1757 {1757 {
1758 PSI_stage_info old_stage;1758 PSI_stage_info old_stage;
@@ -1805,7 +1805,7 @@
1805 DBUG_ENTER("slave_worker_exec_job");1805 DBUG_ENTER("slave_worker_exec_job");
18061806
1807 job_item= pop_jobs_item(worker, job_item);1807 job_item= pop_jobs_item(worker, job_item);
1808 if (thd->killed || worker->running_status != Slave_worker::RUNNING)1808 if (thd->get_killed() || worker->running_status != Slave_worker::RUNNING)
1809 {1809 {
1810 // de-queueing and decrement counters is in the caller's exit branch1810 // de-queueing and decrement counters is in the caller's exit branch
1811 error= -1;1811 error= -1;
@@ -1978,7 +1978,7 @@
1978 if (log_warnings > 1)1978 if (log_warnings > 1)
1979 sql_print_information("Worker %lu is exiting: killed %i, error %i, "1979 sql_print_information("Worker %lu is exiting: killed %i, error %i, "
1980 "running_status %d",1980 "running_status %d",
1981 worker->id, thd->killed, thd->is_error(),1981 worker->id, thd->get_killed(), thd->is_error(),
1982 worker->running_status);1982 worker->running_status);
1983 worker->slave_worker_ends_group(ev, error);1983 worker->slave_worker_ends_group(ev, error);
1984 }1984 }
19851985
=== modified file 'Percona-Server/sql/rpl_slave.cc'
--- Percona-Server/sql/rpl_slave.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/rpl_slave.cc 2013-01-09 13:41:38 +0000
@@ -1034,15 +1034,15 @@
1034 /*1034 /*
1035 It is not sufficient to test this at loop bottom. We must test1035 It is not sufficient to test this at loop bottom. We must test
1036 it after registering the mutex in enter_cond(). If the kill1036 it after registering the mutex in enter_cond(). If the kill
1037 happens after testing of thd->killed and before the mutex is1037 happens after testing of thd->get_killed() and before the mutex is
1038 registered, we could otherwise go waiting though thd->killed is1038 registered, we could otherwise go waiting though thd->get_killed() is
1039 set.1039 set.
1040 */1040 */
1041 if (!thd->killed)1041 if (!thd->get_killed())
1042 mysql_cond_wait(start_cond, cond_lock);1042 mysql_cond_wait(start_cond, cond_lock);
1043 thd->EXIT_COND(& saved_stage);1043 thd->EXIT_COND(& saved_stage);
1044 mysql_mutex_lock(cond_lock); // re-acquire it as exit_cond() released1044 mysql_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
1045 if (thd->killed)1045 if (thd->get_killed())
1046 {1046 {
1047 if (start_lock)1047 if (start_lock)
1048 mysql_mutex_unlock(start_lock);1048 mysql_mutex_unlock(start_lock);
@@ -1192,7 +1192,7 @@
11921192
1193 DBUG_ASSERT(mi->info_thd == thd);1193 DBUG_ASSERT(mi->info_thd == thd);
1194 DBUG_ASSERT(mi->slave_running); // tracking buffer overrun1194 DBUG_ASSERT(mi->slave_running); // tracking buffer overrun
1195 DBUG_RETURN(mi->abort_slave || abort_loop || thd->killed);1195 DBUG_RETURN(mi->abort_slave || abort_loop || thd->get_killed());
1196}1196}
11971197
1198/**1198/**
@@ -1223,10 +1223,10 @@
12231223
1224 DBUG_ASSERT(rli->info_thd == thd);1224 DBUG_ASSERT(rli->info_thd == thd);
1225 DBUG_ASSERT(rli->slave_running == 1);1225 DBUG_ASSERT(rli->slave_running == 1);
1226 if (abort_loop || thd->killed || rli->abort_slave)1226 if (abort_loop || thd->get_killed() || rli->abort_slave)
1227 {1227 {
1228 is_parallel_warn= (rli->is_parallel_exec() && 1228 is_parallel_warn= (rli->is_parallel_exec() &&
1229 (rli->is_mts_in_group() || thd->killed));1229 (rli->is_mts_in_group() || thd->get_killed()));
1230 /*1230 /*
1231 Slave can execute stop being in one of two MTS or Single-Threaded mode.1231 Slave can execute stop being in one of two MTS or Single-Threaded mode.
1232 The modes define different criteria to accept the stop.1232 The modes define different criteria to accept the stop.
@@ -5153,7 +5153,7 @@
5153 commit-events of last assigned groups.5153 commit-events of last assigned groups.
5154 */5154 */
5155 if (rli->mts_group_status != Relay_log_info::MTS_KILLED_GROUP &&5155 if (rli->mts_group_status != Relay_log_info::MTS_KILLED_GROUP &&
5156 thd->killed == THD::NOT_KILLED)5156 thd->get_killed() == THD::NOT_KILLED)
5157 {5157 {
5158 DBUG_ASSERT(rli->mts_group_status != Relay_log_info::MTS_IN_GROUP ||5158 DBUG_ASSERT(rli->mts_group_status != Relay_log_info::MTS_IN_GROUP ||
5159 thd->is_error());5159 thd->is_error());
@@ -7166,7 +7166,7 @@
7166 set_timespec_nsec(waittime, period);7166 set_timespec_nsec(waittime, period);
7167 ret= rli->relay_log.wait_for_update_relay_log(thd, &waittime);7167 ret= rli->relay_log.wait_for_update_relay_log(thd, &waittime);
7168 } while ((ret == ETIMEDOUT || ret == ETIME) /* todo:remove */ &&7168 } while ((ret == ETIMEDOUT || ret == ETIME) /* todo:remove */ &&
7169 signal_cnt == rli->relay_log.signal_cnt && !thd->killed);7169 signal_cnt == rli->relay_log.signal_cnt && !thd->get_killed());
7170 }7170 }
7171 else7171 else
7172 {7172 {
71737173
=== modified file 'Percona-Server/sql/signal_handler.cc'
--- Percona-Server/sql/signal_handler.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/sql/signal_handler.cc 2013-01-09 13:41:38 +0000
@@ -165,7 +165,7 @@
165 if (thd)165 if (thd)
166 {166 {
167 const char *kreason= "UNKNOWN";167 const char *kreason= "UNKNOWN";
168 switch (thd->killed) {168 switch (thd->get_killed()) {
169 case THD::NOT_KILLED:169 case THD::NOT_KILLED:
170 kreason= "NOT_KILLED";170 kreason= "NOT_KILLED";
171 break;171 break;
172172
=== modified file 'Percona-Server/sql/sp.cc'
--- Percona-Server/sql/sp.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sp.cc 2013-01-09 13:41:38 +0000
@@ -1484,7 +1484,7 @@
1484 or is outdated. We therefore only abort mysql_rm_db() if we1484 or is outdated. We therefore only abort mysql_rm_db() if we
1485 have errors not handled by the error handler.1485 have errors not handled by the error handler.
1486 */1486 */
1487 DBUG_RETURN(thd->is_error() || thd->killed);1487 DBUG_RETURN(thd->is_error() || thd->get_killed());
1488 }1488 }
14891489
1490 table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info);1490 table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info);
@@ -2077,7 +2077,7 @@
2077 break;2077 break;
2078 default:2078 default:
2079 /* Query might have been killed, don't set error. */2079 /* Query might have been killed, don't set error. */
2080 if (thd->killed)2080 if (thd->get_killed())
2081 break;2081 break;
2082 /*2082 /*
2083 Any error when loading an existing routine is either some problem2083 Any error when loading an existing routine is either some problem
20842084
=== modified file 'Percona-Server/sql/sp_head.cc'
--- Percona-Server/sql/sp_head.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/sql/sp_head.cc 2013-01-09 13:41:38 +0000
@@ -675,7 +675,7 @@
675 /* Reset sp_rcontext::end_partial_result_set flag. */675 /* Reset sp_rcontext::end_partial_result_set flag. */
676 thd->sp_runtime_ctx->end_partial_result_set= FALSE;676 thd->sp_runtime_ctx->end_partial_result_set= FALSE;
677677
678 } while (!err_status && !thd->killed && !thd->is_fatal_error);678 } while (!err_status && !thd->get_killed() && !thd->is_fatal_error);
679679
680#if defined(ENABLED_PROFILING)680#if defined(ENABLED_PROFILING)
681 thd->profiling.finish_current_query();681 thd->profiling.finish_current_query();
@@ -751,16 +751,16 @@
751751
752 done:752 done:
753 DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d",753 DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d",
754 err_status, thd->killed, thd->is_slave_error,754 err_status, thd->get_killed(), thd->is_slave_error,
755 thd->is_error()));755 thd->is_error()));
756756
757 if (thd->killed)757 if (thd->get_killed())
758 err_status= TRUE;758 err_status= TRUE;
759 /*759 /*
760 If the DB has changed, the pointer has changed too, but the760 If the DB has changed, the pointer has changed too, but the
761 original thd->db will then have been freed761 original thd->db will then have been freed
762 */762 */
763 if (cur_db_changed && thd->killed != THD::KILL_CONNECTION)763 if (cur_db_changed && thd->get_killed() != THD::KILL_CONNECTION)
764 {764 {
765 /*765 /*
766 Force switching back to the saved current database, because it may be766 Force switching back to the saved current database, because it may be
@@ -901,7 +901,7 @@
901 free_root(&call_mem_root, MYF(0));901 free_root(&call_mem_root, MYF(0));
902 thd->sp_runtime_ctx= parent_sp_runtime_ctx;902 thd->sp_runtime_ctx= parent_sp_runtime_ctx;
903903
904 if (thd->killed)904 if (thd->get_killed())
905 thd->send_kill_message();905 thd->send_kill_message();
906906
907 DBUG_RETURN(err_status);907 DBUG_RETURN(err_status);
@@ -1096,7 +1096,7 @@
1096 thd->variables.option_bits= binlog_save_options;1096 thd->variables.option_bits= binlog_save_options;
1097 if (thd->binlog_evt_union.unioned_events)1097 if (thd->binlog_evt_union.unioned_events)
1098 {1098 {
1099 int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED);1099 int errcode = query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
1100 Query_log_event qinfo(thd, binlog_buf.ptr(), binlog_buf.length(),1100 Query_log_event qinfo(thd, binlog_buf.ptr(), binlog_buf.length(),
1101 thd->binlog_evt_union.unioned_events_trans, FALSE, FALSE, errcode);1101 thd->binlog_evt_union.unioned_events_trans, FALSE, FALSE, errcode);
1102 if (mysql_bin_log.write_event(&qinfo) &&1102 if (mysql_bin_log.write_event(&qinfo) &&
11031103
=== modified file 'Percona-Server/sql/sp_instr.cc'
--- Percona-Server/sql/sp_instr.cc 2012-07-16 15:43:41 +0000
+++ Percona-Server/sql/sp_instr.cc 2013-01-09 13:41:38 +0000
@@ -630,7 +630,7 @@
630 */630 */
631 if (stmt_reprepare_observer &&631 if (stmt_reprepare_observer &&
632 !thd->is_fatal_error &&632 !thd->is_fatal_error &&
633 !thd->killed &&633 !thd->get_killed() &&
634 thd->get_stmt_da()->sql_errno() == ER_NEED_REPREPARE &&634 thd->get_stmt_da()->sql_errno() == ER_NEED_REPREPARE &&
635 reprepare_attempt++ < 3)635 reprepare_attempt++ < 3)
636 {636 {
637637
=== modified file 'Percona-Server/sql/sp_rcontext.cc'
--- Percona-Server/sql/sp_rcontext.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sp_rcontext.cc 2013-01-09 13:41:38 +0000
@@ -353,7 +353,7 @@
353353
354 /* Reset error state. */354 /* Reset error state. */
355 thd->clear_error();355 thd->clear_error();
356 thd->killed= THD::NOT_KILLED; // Some errors set thd->killed356 thd->set_killed(THD::NOT_KILLED); // Some errors set thd->get_killed()
357 // (e.g. "bad data").357 // (e.g. "bad data").
358358
359 /* Add a frame to handler-call-stack. */359 /* Add a frame to handler-call-stack. */
360360
=== modified file 'Percona-Server/sql/sql_admin.cc'
--- Percona-Server/sql/sql_admin.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/sql/sql_admin.cc 2013-01-09 13:41:38 +0000
@@ -804,7 +804,7 @@
804 protocol->store(operator_name, system_charset_info);804 protocol->store(operator_name, system_charset_info);
805 if (result_code) // either mysql_recreate_table or analyze failed805 if (result_code) // either mysql_recreate_table or analyze failed
806 {806 {
807 DBUG_ASSERT(thd->is_error() || thd->killed);807 DBUG_ASSERT(thd->is_error() || thd->get_killed());
808 if (thd->is_error())808 if (thd->is_error())
809 {809 {
810 const char *err_msg= thd->get_stmt_da()->message();810 const char *err_msg= thd->get_stmt_da()->message();
811811
=== modified file 'Percona-Server/sql/sql_base.cc'
--- Percona-Server/sql/sql_base.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_base.cc 2013-01-09 13:41:38 +0000
@@ -850,9 +850,9 @@
850 THD *in_use= tab->in_use;850 THD *in_use= tab->in_use;
851851
852 if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&852 if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
853 ! in_use->killed)853 ! in_use->get_killed())
854 {854 {
855 in_use->killed= THD::KILL_CONNECTION;855 in_use->set_killed(THD::KILL_CONNECTION);
856 mysql_mutex_lock(&in_use->mysys_var->mutex);856 mysql_mutex_lock(&in_use->mysys_var->mutex);
857 if (in_use->mysys_var->current_cond)857 if (in_use->mysys_var->current_cond)
858 {858 {
@@ -983,7 +983,7 @@
983 /* Wait until all threads have closed all the tables we are flushing. */983 /* Wait until all threads have closed all the tables we are flushing. */
984 DBUG_PRINT("info", ("Waiting for other threads to close their open tables"));984 DBUG_PRINT("info", ("Waiting for other threads to close their open tables"));
985985
986 while (found && ! thd->killed)986 while (found && ! thd->get_killed())
987 {987 {
988 TABLE_SHARE *share;988 TABLE_SHARE *share;
989 found= FALSE;989 found= FALSE;
@@ -2594,7 +2594,7 @@
2594 if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias))2594 if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias))
2595 DBUG_RETURN(TRUE);2595 DBUG_RETURN(TRUE);
25962596
2597 if (thd->killed)2597 if (thd->get_killed())
2598 DBUG_RETURN(TRUE);2598 DBUG_RETURN(TRUE);
25992599
2600 key_length= get_table_def_key(table_list, &key);2600 key_length= get_table_def_key(table_list, &key);
@@ -3530,7 +3530,7 @@
3530 mysql_lock_merge(thd->lock, lock)) == NULL)3530 mysql_lock_merge(thd->lock, lock)) == NULL)
3531 {3531 {
3532 unlink_all_closed_tables(thd, lock, reopen_count);3532 unlink_all_closed_tables(thd, lock, reopen_count);
3533 if (! thd->killed)3533 if (! thd->get_killed())
3534 my_error(ER_LOCK_DEADLOCK, MYF(0));3534 my_error(ER_LOCK_DEADLOCK, MYF(0));
3535 return TRUE;3535 return TRUE;
3536 }3536 }
35373537
=== modified file 'Percona-Server/sql/sql_cache.cc'
--- Percona-Server/sql/sql_cache.cc 2012-10-03 12:51:45 +0000
+++ Percona-Server/sql/sql_cache.cc 2013-01-09 13:41:38 +0000
@@ -1001,7 +1001,7 @@
1001 if (query_cache_tls->first_query_block == NULL)1001 if (query_cache_tls->first_query_block == NULL)
1002 DBUG_VOID_RETURN;1002 DBUG_VOID_RETURN;
10031003
1004 if (thd->killed || thd->is_error())1004 if (thd->get_killed() || thd->is_error())
1005 {1005 {
1006 query_cache_abort(&thd->query_cache_tls);1006 query_cache_abort(&thd->query_cache_tls);
1007 DBUG_VOID_RETURN;1007 DBUG_VOID_RETURN;
@@ -4239,7 +4239,7 @@
4239 DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line));4239 DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line));
4240 DBUG_PRINT("warning", ("=================================="));4240 DBUG_PRINT("warning", ("=================================="));
4241 if (thd)4241 if (thd)
4242 thd->killed= THD::KILL_CONNECTION;4242 thd->set_killed(THD::KILL_CONNECTION);
4243 cache_dump();4243 cache_dump();
4244 /* check_integrity(0); */ /* Can't call it here because of locks */4244 /* check_integrity(0); */ /* Can't call it here because of locks */
4245 bins_dump();4245 bins_dump();
42464246
=== modified file 'Percona-Server/sql/sql_class.cc'
--- Percona-Server/sql/sql_class.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_class.cc 2013-01-09 13:41:38 +0000
@@ -273,7 +273,7 @@
273*/273*/
274void thd_set_killed(THD *thd)274void thd_set_killed(THD *thd)
275{275{
276 thd->killed= THD::KILL_CONNECTION;276 thd->set_killed(THD::KILL_CONNECTION);
277}277}
278278
279/**279/**
@@ -928,7 +928,7 @@
928 password= 0;928 password= 0;
929 query_start_used= query_start_usec_used= 0;929 query_start_used= query_start_usec_used= 0;
930 count_cuted_fields= CHECK_FIELD_IGNORE;930 count_cuted_fields= CHECK_FIELD_IGNORE;
931 killed= NOT_KILLED;931 set_killed(NOT_KILLED);
932 col_access=0;932 col_access=0;
933 is_slave_error= thread_specific_used= FALSE;933 is_slave_error= thread_specific_used= FALSE;
934 my_hash_clear(&handler_tables_hash);934 my_hash_clear(&handler_tables_hash);
@@ -945,6 +945,7 @@
945 start_time.tv_sec= 0;945 start_time.tv_sec= 0;
946 start_time.tv_usec= 0;946 start_time.tv_usec= 0;
947 start_utime= prior_thr_create_utime= 0L;947 start_utime= prior_thr_create_utime= 0L;
948 sql_timeout_expire= 0;
948 utime_after_lock= 0L;949 utime_after_lock= 0L;
949 current_linfo = 0;950 current_linfo = 0;
950 slave_thread = 0;951 slave_thread = 0;
@@ -1227,7 +1228,7 @@
1227 push_warning and strict SQL_MODE case.1228 push_warning and strict SQL_MODE case.
1228 */1229 */
1229 level= Sql_condition::WARN_LEVEL_ERROR;1230 level= Sql_condition::WARN_LEVEL_ERROR;
1230 killed= THD::KILL_BAD_DATA;1231 set_killed(THD::KILL_BAD_DATA);
1231 }1232 }
12321233
1233 switch (level)1234 switch (level)
@@ -1433,7 +1434,7 @@
1433 mysql_mutex_unlock(&LOCK_status);1434 mysql_mutex_unlock(&LOCK_status);
14341435
1435 cleanup();1436 cleanup();
1436 killed= NOT_KILLED;1437 set_killed(NOT_KILLED);
1437 cleanup_done= 0;1438 cleanup_done= 0;
1438 init();1439 init();
1439 stmt_map.reset();1440 stmt_map.reset();
@@ -1454,7 +1455,7 @@
1454 DBUG_ENTER("THD::cleanup");1455 DBUG_ENTER("THD::cleanup");
1455 DBUG_ASSERT(cleanup_done == 0);1456 DBUG_ASSERT(cleanup_done == 0);
14561457
1457 killed= KILL_CONNECTION;1458 set_killed(KILL_CONNECTION);
1458#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE1459#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
1459 if (transaction.xid_state.xa_state == XA_PREPARED)1460 if (transaction.xid_state.xa_state == XA_PREPARED)
1460 {1461 {
@@ -1692,7 +1693,7 @@
1692 mysql_mutex_assert_owner(&LOCK_thd_data);1693 mysql_mutex_assert_owner(&LOCK_thd_data);
16931694
1694 /* Set the 'killed' flag of 'this', which is the target THD object. */1695 /* Set the 'killed' flag of 'this', which is the target THD object. */
1695 killed= state_to_set;1696 set_killed(state_to_set);
16961697
1697 if (state_to_set != THD::KILL_QUERY)1698 if (state_to_set != THD::KILL_QUERY)
1698 {1699 {
@@ -1713,7 +1714,7 @@
17131714
1714 On the other hand, without closing the socket we have a race1715 On the other hand, without closing the socket we have a race
1715 condition. If "this" target thread passes the check of1716 condition. If "this" target thread passes the check of
1716 thd->killed, and then the current thread runs through1717 thd->get_killed(), and then the current thread runs through
1717 THD::awake(), sets the 'killed' flag and completes the1718 THD::awake(), sets the 'killed' flag and completes the
1718 signaling, and then the target thread runs into read(), it will1719 signaling, and then the target thread runs into read(), it will
1719 block on the socket. As a result of the discussions around1720 block on the socket. As a result of the discussions around
@@ -1721,7 +1722,7 @@
1721 condition. A second KILL awakes the target from read().1722 condition. A second KILL awakes the target from read().
17221723
1723 If we are killing ourselves, we know that we are not blocked.1724 If we are killing ourselves, we know that we are not blocked.
1724 We also know that we will check thd->killed before we go for1725 We also know that we will check thd->get_killed() before we go for
1725 reading the next statement.1726 reading the next statement.
1726 */1727 */
17271728
@@ -1759,7 +1760,7 @@
1759 current_cond and current_mutex are 0), then the victim will not get1760 current_cond and current_mutex are 0), then the victim will not get
1760 a signal and it may wait "forever" on the cond (until1761 a signal and it may wait "forever" on the cond (until
1761 we issue a second KILL or the status it's waiting for happens).1762 we issue a second KILL or the status it's waiting for happens).
1762 It's true that we have set its thd->killed but it may not1763 It's true that we have set its thd->get_killed() but it may not
1763 see it immediately and so may have time to reach the cond_wait().1764 see it immediately and so may have time to reach the cond_wait().
17641765
1765 However, where possible, we test for killed once again after1766 However, where possible, we test for killed once again after
@@ -1792,7 +1793,7 @@
17921793
1793 mysql_mutex_lock(&LOCK_thd_data);1794 mysql_mutex_lock(&LOCK_thd_data);
17941795
1795 killed= THD::KILL_CONNECTION;1796 set_killed(THD::KILL_CONNECTION);
17961797
1797#ifdef SIGNAL_WITH_VIO_CLOSE1798#ifdef SIGNAL_WITH_VIO_CLOSE
1798 /*1799 /*
@@ -1820,9 +1821,9 @@
1820 THD *in_use= ctx_in_use->get_thd();1821 THD *in_use= ctx_in_use->get_thd();
1821 bool signalled= FALSE;1822 bool signalled= FALSE;
1822 if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&1823 if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
1823 !in_use->killed)1824 !in_use->get_killed())
1824 {1825 {
1825 in_use->killed= THD::KILL_CONNECTION;1826 in_use->set_killed(THD::KILL_CONNECTION);
1826 mysql_mutex_lock(&in_use->mysys_var->mutex);1827 mysql_mutex_lock(&in_use->mysys_var->mutex);
1827 if (in_use->mysys_var->current_cond)1828 if (in_use->mysys_var->current_cond)
1828 mysql_cond_broadcast(in_use->mysys_var->current_cond);1829 mysql_cond_broadcast(in_use->mysys_var->current_cond);
@@ -2185,7 +2186,7 @@
2185 {2186 {
2186 my_error(EE_OUTOFMEMORY, MYF(ME_BELL),2187 my_error(EE_OUTOFMEMORY, MYF(ME_BELL),
2187 ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1);2188 ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1);
2188 killed= KILL_CONNECTION;2189 set_killed(KILL_CONNECTION);
2189 return 0;2190 return 0;
2190 }2191 }
21912192
@@ -3992,7 +3993,7 @@
3992*/3993*/
3993extern "C" int thd_killed(const MYSQL_THD thd)3994extern "C" int thd_killed(const MYSQL_THD thd)
3994{3995{
3995 return(thd->killed);3996 return(thd->get_killed());
3996}3997}
39973998
3998/**3999/**
39994000
=== modified file 'Percona-Server/sql/sql_class.h'
--- Percona-Server/sql/sql_class.h 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_class.h 2013-01-09 13:41:38 +0000
@@ -481,6 +481,7 @@
481 ulong trans_alloc_block_size;481 ulong trans_alloc_block_size;
482 ulong trans_prealloc_size;482 ulong trans_prealloc_size;
483 ulong group_concat_max_len;483 ulong group_concat_max_len;
484 ulong sql_timeout;
484485
485 ulong binlog_format; ///< binlog format for this thd (see enum_binlog_format)486 ulong binlog_format; ///< binlog format for this thd (see enum_binlog_format)
486 my_bool binlog_direct_non_trans_update;487 my_bool binlog_direct_non_trans_update;
@@ -2124,6 +2125,12 @@
2124 uint16 peer_port;2125 uint16 peer_port;
2125 struct timeval start_time;2126 struct timeval start_time;
2126 struct timeval user_time;2127 struct timeval user_time;
2128 /*
2129 Expire time in microseconds for sql_timeout monitor thread. The 0 value
2130 means the current thread is not monitored by sql_timeout monitor.
2131 */
2132 ulonglong sql_timeout_expire;
2133
2127 // track down slow pthread_create2134 // track down slow pthread_create
2128 ulonglong prior_thr_create_utime, thr_create_utime;2135 ulonglong prior_thr_create_utime, thr_create_utime;
2129 ulonglong start_utime, utime_after_lock;2136 ulonglong start_utime, utime_after_lock;
@@ -2807,7 +2814,27 @@
2807 KILL_QUERY=ER_QUERY_INTERRUPTED,2814 KILL_QUERY=ER_QUERY_INTERRUPTED,
2808 KILLED_NO_VALUE /* means neither of the states */2815 KILLED_NO_VALUE /* means neither of the states */
2809 };2816 };
2810 killed_state volatile killed;2817
2818private:
2819 killed_state volatile killed_status;
2820
2821public:
2822 killed_state get_killed() const
2823 {
2824 if (killed_status)
2825 return killed_status;
2826 if (sql_timeout_expire &&
2827 (my_micro_time() >= sql_timeout_expire))
2828 {
2829 return THD::KILL_QUERY;
2830 }
2831 return killed_status;
2832 }
2833
2834 void set_killed(killed_state new_killed)
2835 {
2836 killed_status= new_killed;
2837 }
28112838
2812 /* scramble - random string sent to client on handshake */2839 /* scramble - random string sent to client on handshake */
2813 char scramble[SCRAMBLE_LENGTH+1];2840 char scramble[SCRAMBLE_LENGTH+1];
@@ -3080,7 +3107,7 @@
3080 DBUG_VOID_RETURN;3107 DBUG_VOID_RETURN;
3081 }3108 }
30823109
3083 virtual int is_killed() { return killed; }3110 virtual int is_killed() { return get_killed(); }
3084 virtual THD* get_thd() { return this; }3111 virtual THD* get_thd() { return this; }
30853112
3086 /**3113 /**
@@ -3331,7 +3358,7 @@
3331 */3358 */
3332 inline void fatal_error()3359 inline void fatal_error()
3333 {3360 {
3334 DBUG_ASSERT(get_stmt_da()->is_error() || killed);3361 DBUG_ASSERT(get_stmt_da()->is_error() || get_killed());
3335 is_fatal_error= 1;3362 is_fatal_error= 1;
3336 DBUG_PRINT("error",("Fatal error set"));3363 DBUG_PRINT("error",("Fatal error set"));
3337 }3364 }
@@ -3420,7 +3447,7 @@
3420 inline int killed_errno() const3447 inline int killed_errno() const
3421 {3448 {
3422 killed_state killed_val; /* to cache the volatile 'killed' */3449 killed_state killed_val; /* to cache the volatile 'killed' */
3423 return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;3450 return (killed_val= get_killed()) != KILL_BAD_DATA ? killed_val : 0;
3424 }3451 }
3425 inline void send_kill_message() const3452 inline void send_kill_message() const
3426 {3453 {
34273454
=== modified file 'Percona-Server/sql/sql_connect.cc'
--- Percona-Server/sql/sql_connect.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_connect.cc 2013-01-09 13:41:38 +0000
@@ -768,14 +768,14 @@
768 */768 */
769 release_user_connection(thd);769 release_user_connection(thd);
770770
771 if (thd->killed || (net->error && net->vio != 0))771 if (thd->get_killed() || (net->error && net->vio != 0))
772 {772 {
773 statistic_increment(aborted_threads,&LOCK_status);773 statistic_increment(aborted_threads,&LOCK_status);
774 }774 }
775775
776 if (net->error && net->vio != 0)776 if (net->error && net->vio != 0)
777 {777 {
778 if (!thd->killed && log_warnings > 1)778 if (!thd->get_killed() && log_warnings > 1)
779 {779 {
780 Security_context *sctx= thd->security_ctx;780 Security_context *sctx= thd->security_ctx;
781781
@@ -846,7 +846,7 @@
846846
847 thd->server_status&= ~SERVER_STATUS_CLEAR_SET;847 thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
848 thd->protocol->end_statement();848 thd->protocol->end_statement();
849 thd->killed = THD::KILL_CONNECTION;849 thd->set_killed(THD::KILL_CONNECTION);
850 errors.m_init_connect= 1;850 errors.m_init_connect= 1;
851 inc_host_errors(thd->main_security_ctx.ip, &errors);851 inc_host_errors(thd->main_security_ctx.ip, &errors);
852 return;852 return;
@@ -907,7 +907,7 @@
907 NET *net= &thd->net;907 NET *net= &thd->net;
908 if (!net->error &&908 if (!net->error &&
909 net->vio != 0 &&909 net->vio != 0 &&
910 !(thd->killed == THD::KILL_CONNECTION))910 !(thd->get_killed() == THD::KILL_CONNECTION))
911 return TRUE;911 return TRUE;
912 return FALSE;912 return FALSE;
913}913}
914914
=== modified file 'Percona-Server/sql/sql_db.cc'
--- Percona-Server/sql/sql_db.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_db.cc 2013-01-09 13:41:38 +0000
@@ -840,7 +840,7 @@
840 }840 }
841841
842 thd->push_internal_handler(&err_handler);842 thd->push_internal_handler(&err_handler);
843 if (!thd->killed &&843 if (!thd->get_killed() &&
844 !(tables &&844 !(tables &&
845 mysql_rm_table_no_locks(thd, tables, true, false, true, true)))845 mysql_rm_table_no_locks(thd, tables, true, false, true, true)))
846 {846 {
@@ -1025,7 +1025,7 @@
1025 tot_list_next_local= tot_list_next_global= &tot_list;1025 tot_list_next_local= tot_list_next_global= &tot_list;
10261026
1027 for (uint idx=0 ;1027 for (uint idx=0 ;
1028 idx < (uint) dirp->number_off_files && !thd->killed ;1028 idx < (uint) dirp->number_off_files && !thd->get_killed() ;
1029 idx++)1029 idx++)
1030 {1030 {
1031 FILEINFO *file=dirp->dir_entry+idx;1031 FILEINFO *file=dirp->dir_entry+idx;
@@ -1206,7 +1206,7 @@
1206 DBUG_PRINT("enter", ("path: %s", org_path));1206 DBUG_PRINT("enter", ("path: %s", org_path));
12071207
1208 for (uint idx=0 ;1208 for (uint idx=0 ;
1209 idx < (uint) dirp->number_off_files && !thd->killed ;1209 idx < (uint) dirp->number_off_files && !thd->get_killed() ;
1210 idx++)1210 idx++)
1211 {1211 {
1212 FILEINFO *file=dirp->dir_entry+idx;1212 FILEINFO *file=dirp->dir_entry+idx;
@@ -1241,7 +1241,7 @@
1241 }1241 }
1242 deleted++;1242 deleted++;
1243 }1243 }
1244 if (thd->killed)1244 if (thd->get_killed())
1245 goto err;1245 goto err;
12461246
1247 my_dirend(dirp);1247 my_dirend(dirp);
@@ -1710,7 +1710,7 @@
1710 if ((dirp = my_dir(path,MYF(MY_DONT_SORT))))1710 if ((dirp = my_dir(path,MYF(MY_DONT_SORT))))
1711 {1711 {
1712 uint nfiles= (uint) dirp->number_off_files;1712 uint nfiles= (uint) dirp->number_off_files;
1713 for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++)1713 for (uint idx=0 ; idx < nfiles && !thd->get_killed() ; idx++)
1714 {1714 {
1715 FILEINFO *file= dirp->dir_entry + idx;1715 FILEINFO *file= dirp->dir_entry + idx;
1716 char *extension, tname[FN_REFLEN + 1];1716 char *extension, tname[FN_REFLEN + 1];
17171717
=== modified file 'Percona-Server/sql/sql_delete.cc'
--- Percona-Server/sql/sql_delete.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_delete.cc 2013-01-09 13:41:38 +0000
@@ -350,7 +350,7 @@
350 select && select->quick && select->quick->index != MAX_KEY)350 select && select->quick && select->quick->index != MAX_KEY)
351 read_removal= table->check_read_removal(select->quick->index);351 read_removal= table->check_read_removal(select->quick->index);
352352
353 while (!(error=info.read_record(&info)) && !thd->killed &&353 while (!(error=info.read_record(&info)) && !thd->get_killed() &&
354 ! thd->is_error())354 ! thd->is_error())
355 {355 {
356 thd->inc_examined_row_count(1);356 thd->inc_examined_row_count(1);
@@ -406,7 +406,7 @@
406 else406 else
407 break;407 break;
408 }408 }
409 killed_status= thd->killed;409 killed_status= thd->get_killed();
410 if (killed_status != THD::NOT_KILLED || thd->is_error())410 if (killed_status != THD::NOT_KILLED || thd->is_error())
411 error= 1; // Aborted411 error= 1; // Aborted
412 if (will_batch && (loc_error= table->file->end_bulk_delete()))412 if (will_batch && (loc_error= table->file->end_bulk_delete()))
@@ -479,7 +479,7 @@
479 my_ok(thd, deleted);479 my_ok(thd, deleted);
480 DBUG_PRINT("info",("%ld records deleted",(long) deleted));480 DBUG_PRINT("info",("%ld records deleted",(long) deleted));
481 }481 }
482 DBUG_RETURN(thd->is_error() || thd->killed);482 DBUG_RETURN(thd->is_error() || thd->get_killed());
483483
484#ifdef WITH_PARTITION_STORAGE_ENGINE484#ifdef WITH_PARTITION_STORAGE_ENGINE
485exit_all_parts_pruned_away:485exit_all_parts_pruned_away:
@@ -496,7 +496,7 @@
496 delete select;496 delete select;
497 free_underlaid_joins(thd, select_lex);497 free_underlaid_joins(thd, select_lex);
498 table->set_keyread(false);498 table->set_keyread(false);
499 DBUG_RETURN((err || thd->is_error() || thd->killed) ? 1 : 0);499 DBUG_RETURN((err || thd->is_error() || thd->get_killed()) ? 1 : 0);
500}500}
501501
502502
@@ -893,7 +893,7 @@
893 */893 */
894 if (mysql_bin_log.is_open())894 if (mysql_bin_log.is_open())
895 {895 {
896 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);896 int errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
897 /* possible error of writing binary log is ignored deliberately */897 /* possible error of writing binary log is ignored deliberately */
898 (void) thd->binlog_query(THD::ROW_QUERY_TYPE,898 (void) thd->binlog_query(THD::ROW_QUERY_TYPE,
899 thd->query(), thd->query_length(),899 thd->query(), thd->query_length(),
@@ -938,7 +938,7 @@
938 int local_error= 938 int local_error=
939 do_table_deletes(table, thd->lex->current_select->no_error);939 do_table_deletes(table, thd->lex->current_select->no_error);
940940
941 if (thd->killed && !local_error)941 if (thd->get_killed() && !local_error)
942 DBUG_RETURN(1);942 DBUG_RETURN(1);
943943
944 if (local_error == -1) // End of file944 if (local_error == -1) // End of file
@@ -980,7 +980,7 @@
980 */980 */
981 info.ignore_not_found_rows= 1;981 info.ignore_not_found_rows= 1;
982 bool will_batch= !table->file->start_bulk_delete();982 bool will_batch= !table->file->start_bulk_delete();
983 while (!(local_error= info.read_record(&info)) && !thd->killed)983 while (!(local_error= info.read_record(&info)) && !thd->get_killed())
984 {984 {
985 if (table->triggers &&985 if (table->triggers &&
986 table->triggers->process_triggers(thd, TRG_EVENT_DELETE,986 table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
@@ -1048,7 +1048,7 @@
10481048
1049 /* compute a total error to know if something failed */1049 /* compute a total error to know if something failed */
1050 local_error= local_error || error;1050 local_error= local_error || error;
1051 killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed;1051 killed_status= (local_error == 0)? THD::NOT_KILLED : thd->get_killed();
1052 /* reset used flags */1052 /* reset used flags */
1053 THD_STAGE_INFO(thd, stage_end);1053 THD_STAGE_INFO(thd, stage_end);
10541054
10551055
=== modified file 'Percona-Server/sql/sql_executor.cc'
--- Percona-Server/sql/sql_executor.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_executor.cc 2013-01-09 13:41:38 +0000
@@ -1033,7 +1033,7 @@
10331033
1034 DBUG_ENTER("sub_select_op");1034 DBUG_ENTER("sub_select_op");
10351035
1036 if (join->thd->killed)1036 if (join->thd->get_killed())
1037 {1037 {
1038 /* The user has aborted the execution of the query */1038 /* The user has aborted the execution of the query */
1039 join->thd->send_kill_message();1039 join->thd->send_kill_message();
@@ -1248,13 +1248,13 @@
1248 else1248 else
1249 error= info->read_record(info);1249 error= info->read_record(info);
12501250
1251 DBUG_EXECUTE_IF("bug13822652_1", join->thd->killed= THD::KILL_QUERY;);1251 DBUG_EXECUTE_IF("bug13822652_1", join->thd->set_killed(THD::KILL_QUERY););
12521252
1253 if (error > 0 || (join->thd->is_error())) // Fatal error1253 if (error > 0 || (join->thd->is_error())) // Fatal error
1254 rc= NESTED_LOOP_ERROR;1254 rc= NESTED_LOOP_ERROR;
1255 else if (error < 0)1255 else if (error < 0)
1256 break;1256 break;
1257 else if (join->thd->killed) // Aborted by user1257 else if (join->thd->get_killed()) // Aborted by user
1258 {1258 {
1259 join->thd->send_kill_message();1259 join->thd->send_kill_message();
1260 rc= NESTED_LOOP_KILLED;1260 rc= NESTED_LOOP_KILLED;
@@ -1450,7 +1450,7 @@
1450 {1450 {
1451 found= test(condition->val_int());1451 found= test(condition->val_int());
14521452
1453 if (join->thd->killed)1453 if (join->thd->get_killed())
1454 {1454 {
1455 join->thd->send_kill_message();1455 join->thd->send_kill_message();
1456 DBUG_RETURN(NESTED_LOOP_KILLED);1456 DBUG_RETURN(NESTED_LOOP_KILLED);
@@ -1737,7 +1737,7 @@
1737 if (error != HA_ERR_LOCK_DEADLOCK &&1737 if (error != HA_ERR_LOCK_DEADLOCK &&
1738 error != HA_ERR_LOCK_WAIT_TIMEOUT &&1738 error != HA_ERR_LOCK_WAIT_TIMEOUT &&
1739 error != HA_ERR_TABLE_DEF_CHANGED &&1739 error != HA_ERR_TABLE_DEF_CHANGED &&
1740 !table->in_use->killed)1740 !table->in_use->get_killed())
1741 sql_print_error("Got error %d when reading table '%s'",1741 sql_print_error("Got error %d when reading table '%s'",
1742 error, table->s->path.str);1742 error, table->s->path.str);
1743 table->file->print_error(error,MYF(0));1743 table->file->print_error(error,MYF(0));
@@ -2922,7 +2922,7 @@
2922 TABLE *const table= join_tab->table;2922 TABLE *const table= join_tab->table;
2923 DBUG_ENTER("end_write");2923 DBUG_ENTER("end_write");
29242924
2925 if (join->thd->killed) // Aborted by user2925 if (join->thd->get_killed()) // Aborted by user
2926 {2926 {
2927 join->thd->send_kill_message();2927 join->thd->send_kill_message();
2928 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */2928 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */
@@ -2977,7 +2977,7 @@
29772977
2978 if (end_of_records)2978 if (end_of_records)
2979 DBUG_RETURN(NESTED_LOOP_OK);2979 DBUG_RETURN(NESTED_LOOP_OK);
2980 if (join->thd->killed) // Aborted by user2980 if (join->thd->get_killed()) // Aborted by user
2981 {2981 {
2982 join->thd->send_kill_message();2982 join->thd->send_kill_message();
2983 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */2983 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */
@@ -3057,7 +3057,7 @@
30573057
3058 if (end_of_records)3058 if (end_of_records)
3059 DBUG_RETURN(NESTED_LOOP_OK);3059 DBUG_RETURN(NESTED_LOOP_OK);
3060 if (join->thd->killed) // Aborted by user3060 if (join->thd->get_killed()) // Aborted by user
3061 {3061 {
3062 join->thd->send_kill_message();3062 join->thd->send_kill_message();
3063 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */3063 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */
@@ -3103,7 +3103,7 @@
3103 int idx= -1;3103 int idx= -1;
3104 DBUG_ENTER("end_write_group");3104 DBUG_ENTER("end_write_group");
31053105
3106 if (join->thd->killed)3106 if (join->thd->get_killed())
3107 { // Aborted by user3107 { // Aborted by user
3108 join->thd->send_kill_message();3108 join->thd->send_kill_message();
3109 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */3109 DBUG_RETURN(NESTED_LOOP_KILLED); /* purecov: inspected */
@@ -3406,7 +3406,7 @@
3406 error=file->ha_rnd_next(record);3406 error=file->ha_rnd_next(record);
3407 for (;;)3407 for (;;)
3408 {3408 {
3409 if (thd->killed)3409 if (thd->get_killed())
3410 {3410 {
3411 thd->send_kill_message();3411 thd->send_kill_message();
3412 error=0;3412 error=0;
@@ -3538,7 +3538,7 @@
3538 for (;;)3538 for (;;)
3539 {3539 {
3540 uchar *org_key_pos;3540 uchar *org_key_pos;
3541 if (thd->killed)3541 if (thd->get_killed())
3542 {3542 {
3543 thd->send_kill_message();3543 thd->send_kill_message();
3544 error=0;3544 error=0;
@@ -4298,7 +4298,7 @@
4298 rc= NESTED_LOOP_ERROR;4298 rc= NESTED_LOOP_ERROR;
4299 else if (error < 0)4299 else if (error < 0)
4300 break;4300 break;
4301 else if (join->thd->killed) // Aborted by user4301 else if (join->thd->get_killed()) // Aborted by user
4302 {4302 {
4303 join->thd->send_kill_message();4303 join->thd->send_kill_message();
4304 rc= NESTED_LOOP_KILLED;4304 rc= NESTED_LOOP_KILLED;
43054305
=== modified file 'Percona-Server/sql/sql_insert.cc'
--- Percona-Server/sql/sql_insert.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_insert.cc 2013-01-09 13:41:38 +0000
@@ -1106,7 +1106,7 @@
1106 thd->clear_error();1106 thd->clear_error();
1107 }1107 }
1108 else1108 else
1109 errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);1109 errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
1110 1110
1111 /* bug#22725:1111 /* bug#22725:
11121112
@@ -1120,7 +1120,7 @@
1120 routines did not result in any error due to the KILLED. In1120 routines did not result in any error due to the KILLED. In
1121 such case the flag is ignored for constructing binlog event.1121 such case the flag is ignored for constructing binlog event.
1122 */1122 */
1123 DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);1123 DBUG_ASSERT(thd->get_killed() != THD::KILL_BAD_DATA || error > 0);
1124 if (was_insert_delayed && table_list->lock_type == TL_WRITE)1124 if (was_insert_delayed && table_list->lock_type == TL_WRITE)
1125 {1125 {
1126 /* Binlog INSERT DELAYED as INSERT without DELAYED. */1126 /* Binlog INSERT DELAYED as INSERT without DELAYED. */
@@ -2201,7 +2201,7 @@
2201 if (!--locks_in_memory)2201 if (!--locks_in_memory)
2202 {2202 {
2203 mysql_mutex_lock(&mutex);2203 mysql_mutex_lock(&mutex);
2204 if (thd.killed && ! stacked_inserts && ! tables_in_use)2204 if (thd.get_killed() && ! stacked_inserts && ! tables_in_use)
2205 {2205 {
2206 mysql_cond_signal(&cond);2206 mysql_cond_signal(&cond);
2207 status=1;2207 status=1;
@@ -2370,18 +2370,18 @@
2370 */2370 */
2371 THD_STAGE_INFO(thd, stage_waiting_for_handler_open);2371 THD_STAGE_INFO(thd, stage_waiting_for_handler_open);
2372 while (!di->handler_thread_initialized ||2372 while (!di->handler_thread_initialized ||
2373 (!di->thd.killed && !di->table && !thd->killed))2373 (!di->thd.get_killed() && !di->table && !thd->get_killed()))
2374 {2374 {
2375 mysql_cond_wait(&di->cond_client, &di->mutex);2375 mysql_cond_wait(&di->cond_client, &di->mutex);
2376 }2376 }
2377 mysql_mutex_unlock(&di->mutex);2377 mysql_mutex_unlock(&di->mutex);
2378 THD_STAGE_INFO(thd, stage_got_old_table);2378 THD_STAGE_INFO(thd, stage_got_old_table);
2379 if (thd->killed)2379 if (thd->get_killed())
2380 {2380 {
2381 di->unlock();2381 di->unlock();
2382 goto end_create;2382 goto end_create;
2383 }2383 }
2384 if (di->thd.killed)2384 if (di->thd.get_killed())
2385 {2385 {
2386 if (di->thd.is_error())2386 if (di->thd.is_error())
2387 {2387 {
@@ -2459,14 +2459,14 @@
2459 {2459 {
2460 THD_STAGE_INFO(client_thd, stage_waiting_for_handler_lock);2460 THD_STAGE_INFO(client_thd, stage_waiting_for_handler_lock);
2461 mysql_cond_signal(&cond); // Tell handler to lock table2461 mysql_cond_signal(&cond); // Tell handler to lock table
2462 while (!thd.killed && !thd.lock && ! client_thd->killed)2462 while (!thd.get_killed() && !thd.lock && ! client_thd->get_killed())
2463 {2463 {
2464 mysql_cond_wait(&cond_client, &mutex);2464 mysql_cond_wait(&cond_client, &mutex);
2465 }2465 }
2466 THD_STAGE_INFO(client_thd, stage_got_handler_lock);2466 THD_STAGE_INFO(client_thd, stage_got_handler_lock);
2467 if (client_thd->killed)2467 if (client_thd->get_killed())
2468 goto error;2468 goto error;
2469 if (thd.killed)2469 if (thd.get_killed())
2470 {2470 {
2471 /*2471 /*
2472 Copy the error message. Note that we don't treat fatal2472 Copy the error message. Note that we don't treat fatal
@@ -2598,11 +2598,11 @@
25982598
2599 THD_STAGE_INFO(thd, stage_waiting_for_handler_insert);2599 THD_STAGE_INFO(thd, stage_waiting_for_handler_insert);
2600 mysql_mutex_lock(&di->mutex);2600 mysql_mutex_lock(&di->mutex);
2601 while (di->stacked_inserts >= delayed_queue_size && !thd->killed)2601 while (di->stacked_inserts >= delayed_queue_size && !thd->get_killed())
2602 mysql_cond_wait(&di->cond_client, &di->mutex);2602 mysql_cond_wait(&di->cond_client, &di->mutex);
2603 THD_STAGE_INFO(thd, stage_storing_row_into_queue);2603 THD_STAGE_INFO(thd, stage_storing_row_into_queue);
26042604
2605 if (thd->killed)2605 if (thd->get_killed())
2606 goto err;2606 goto err;
26072607
2608 /*2608 /*
@@ -2652,7 +2652,7 @@
2652 Delayed_insert *di=thd->di;2652 Delayed_insert *di=thd->di;
2653 mysql_mutex_lock(&di->mutex);2653 mysql_mutex_lock(&di->mutex);
2654 DBUG_PRINT("info",("tables in use: %d",di->tables_in_use));2654 DBUG_PRINT("info",("tables in use: %d",di->tables_in_use));
2655 if (!--di->tables_in_use || di->thd.killed)2655 if (!--di->tables_in_use || di->thd.get_killed())
2656 { // Unlock table2656 { // Unlock table
2657 di->status=1;2657 di->status=1;
2658 mysql_cond_signal(&di->cond);2658 mysql_cond_signal(&di->cond);
@@ -2672,7 +2672,7 @@
2672 Delayed_insert *di;2672 Delayed_insert *di;
2673 while ((di= it++))2673 while ((di= it++))
2674 {2674 {
2675 di->thd.killed= THD::KILL_CONNECTION;2675 di->thd.set_killed(THD::KILL_CONNECTION);
2676 if (di->thd.mysys_var)2676 if (di->thd.mysys_var)
2677 {2677 {
2678 mysql_mutex_lock(&di->thd.mysys_var->mutex);2678 mysql_mutex_lock(&di->thd.mysys_var->mutex);
@@ -2809,7 +2809,7 @@
2809 thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;2809 thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
2810 thd->set_current_time();2810 thd->set_current_time();
2811 add_global_thread(thd);2811 add_global_thread(thd);
2812 thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;2812 thd->set_killed(abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED);
2813 mysql_mutex_unlock(&LOCK_thread_count);2813 mysql_mutex_unlock(&LOCK_thread_count);
28142814
2815 mysql_thread_set_psi_id(thd->thread_id);2815 mysql_thread_set_psi_id(thd->thread_id);
@@ -2882,7 +2882,7 @@
28822882
2883 for (;;)2883 for (;;)
2884 {2884 {
2885 if (thd->killed)2885 if (thd->get_killed())
2886 {2886 {
2887 uint lock_count;2887 uint lock_count;
2888 /*2888 /*
@@ -2900,7 +2900,7 @@
2900 }2900 }
29012901
2902 /* Shouldn't wait if killed or an insert is waiting. */2902 /* Shouldn't wait if killed or an insert is waiting. */
2903 if (!thd->killed && !di->status && !di->stacked_inserts)2903 if (!thd->get_killed() && !di->status && !di->stacked_inserts)
2904 {2904 {
2905 struct timespec abstime;2905 struct timespec abstime;
2906 set_timespec(abstime, delayed_insert_timeout);2906 set_timespec(abstime, delayed_insert_timeout);
@@ -2911,7 +2911,7 @@
2911 THD_STAGE_INFO(&(di->thd), stage_waiting_for_insert);2911 THD_STAGE_INFO(&(di->thd), stage_waiting_for_insert);
29122912
2913 DBUG_PRINT("info",("Waiting for someone to insert rows"));2913 DBUG_PRINT("info",("Waiting for someone to insert rows"));
2914 while (!thd->killed && !di->status)2914 while (!thd->get_killed() && !di->status)
2915 {2915 {
2916 int error;2916 int error;
2917 mysql_audit_release(thd);2917 mysql_audit_release(thd);
@@ -2929,7 +2929,7 @@
2929#endif2929#endif
2930#endif2930#endif
2931 if (error == ETIMEDOUT || error == ETIME)2931 if (error == ETIMEDOUT || error == ETIME)
2932 thd->killed= THD::KILL_CONNECTION;2932 thd->set_killed(THD::KILL_CONNECTION);
2933 }2933 }
2934 /* We can't lock di->mutex and mysys_var->mutex at the same time */2934 /* We can't lock di->mutex and mysys_var->mutex at the same time */
2935 mysql_mutex_unlock(&di->mutex);2935 mysql_mutex_unlock(&di->mutex);
@@ -2940,7 +2940,7 @@
2940 mysql_mutex_lock(&di->mutex);2940 mysql_mutex_lock(&di->mutex);
2941 }2941 }
29422942
2943 if (di->tables_in_use && ! thd->lock && !thd->killed)2943 if (di->tables_in_use && ! thd->lock && !thd->get_killed())
2944 {2944 {
2945 /*2945 /*
2946 Request for new delayed insert.2946 Request for new delayed insert.
@@ -2955,7 +2955,7 @@
2955 if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, 0)))2955 if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, 0)))
2956 {2956 {
2957 /* Fatal error */2957 /* Fatal error */
2958 thd->killed= THD::KILL_CONNECTION;2958 thd->set_killed(THD::KILL_CONNECTION);
2959 }2959 }
2960 mysql_cond_broadcast(&di->cond_client);2960 mysql_cond_broadcast(&di->cond_client);
2961 }2961 }
@@ -2964,7 +2964,7 @@
2964 if (di->handle_inserts())2964 if (di->handle_inserts())
2965 {2965 {
2966 /* Some fatal error */2966 /* Some fatal error */
2967 thd->killed= THD::KILL_CONNECTION;2967 thd->set_killed(THD::KILL_CONNECTION);
2968 }2968 }
2969 }2969 }
2970 di->status=0;2970 di->status=0;
@@ -2999,7 +2999,7 @@
2999 close_thread_tables(thd); // Free the table2999 close_thread_tables(thd); // Free the table
3000 thd->mdl_context.release_transactional_locks();3000 thd->mdl_context.release_transactional_locks();
3001 di->table=0;3001 di->table=0;
3002 thd->killed= THD::KILL_CONNECTION; // If error3002 thd->set_killed(THD::KILL_CONNECTION); // If error
3003 mysql_cond_broadcast(&di->cond_client); // Safety3003 mysql_cond_broadcast(&di->cond_client); // Safety
3004 mysql_mutex_unlock(&di->mutex);3004 mysql_mutex_unlock(&di->mutex);
30053005
@@ -3079,9 +3079,9 @@
30793079
3080 THD_STAGE_INFO(&thd, stage_insert);3080 THD_STAGE_INFO(&thd, stage_insert);
3081 max_rows= delayed_insert_limit;3081 max_rows= delayed_insert_limit;
3082 if (thd.killed || table->s->has_old_version())3082 if (thd.get_killed() || table->s->has_old_version())
3083 {3083 {
3084 thd.killed= THD::KILL_CONNECTION;3084 thd.set_killed(THD::KILL_CONNECTION);
3085 max_rows= ULONG_MAX; // Do as much as possible3085 max_rows= ULONG_MAX; // Do as much as possible
3086 }3086 }
30873087
@@ -3691,7 +3691,7 @@
3691 bool const trans_table= table->file->has_transactions();3691 bool const trans_table= table->file->has_transactions();
3692 ulonglong id, row_count;3692 ulonglong id, row_count;
3693 bool changed;3693 bool changed;
3694 THD::killed_state killed_status= thd->killed;3694 THD::killed_state killed_status= thd->get_killed();
3695 DBUG_ENTER("select_insert::send_eof");3695 DBUG_ENTER("select_insert::send_eof");
3696 DBUG_PRINT("enter", ("trans_table=%d, table_type='%s'",3696 DBUG_PRINT("enter", ("trans_table=%d, table_type='%s'",
3697 trans_table, table->file->table_type()));3697 trans_table, table->file->table_type()));
@@ -3812,7 +3812,7 @@
3812 {3812 {
3813 if (mysql_bin_log.is_open())3813 if (mysql_bin_log.is_open())
3814 {3814 {
3815 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);3815 int errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
3816 /* error of writing binary log is ignored */3816 /* error of writing binary log is ignored */
3817 (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(),3817 (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(),
3818 thd->query_length(),3818 thd->query_length(),
@@ -4221,7 +4221,7 @@
42214221
4222 if (mysql_bin_log.is_open())4222 if (mysql_bin_log.is_open())
4223 {4223 {
4224 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);4224 int errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
4225 result= thd->binlog_query(THD::STMT_QUERY_TYPE,4225 result= thd->binlog_query(THD::STMT_QUERY_TYPE,
4226 query.ptr(), query.length(),4226 query.ptr(), query.length(),
4227 /* is_trans */ TRUE,4227 /* is_trans */ TRUE,
42284228
=== modified file 'Percona-Server/sql/sql_join_buffer.cc'
--- Percona-Server/sql/sql_join_buffer.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/sql/sql_join_buffer.cc 2013-01-09 13:41:38 +0000
@@ -1839,7 +1839,7 @@
1839 if (join_tab->keep_current_rowid)1839 if (join_tab->keep_current_rowid)
1840 join_tab->table->file->position(join_tab->table->record[0]);1840 join_tab->table->file->position(join_tab->table->record[0]);
18411841
1842 if (join->thd->killed)1842 if (join->thd->get_killed())
1843 {1843 {
1844 /* The user has aborted the execution of the query */1844 /* The user has aborted the execution of the query */
1845 join->thd->send_kill_message();1845 join->thd->send_kill_message();
@@ -2121,7 +2121,7 @@
21212121
2122 for ( ; cnt; cnt--)2122 for ( ; cnt; cnt--)
2123 {2123 {
2124 if (join->thd->killed)2124 if (join->thd->get_killed())
2125 {2125 {
2126 /* The user has aborted the execution of the query */2126 /* The user has aborted the execution of the query */
2127 join->thd->send_kill_message();2127 join->thd->send_kill_message();
@@ -2331,7 +2331,7 @@
23312331
2332 while (!(error= file->multi_range_read_next((char **) &rec_ptr)))2332 while (!(error= file->multi_range_read_next((char **) &rec_ptr)))
2333 {2333 {
2334 if (join->thd->killed)2334 if (join->thd->get_killed())
2335 {2335 {
2336 /* The user has aborted the execution of the query */2336 /* The user has aborted the execution of the query */
2337 join->thd->send_kill_message();2337 join->thd->send_kill_message();
@@ -3261,7 +3261,7 @@
3261 next_rec_ref_ptr= get_next_rec_ref(next_rec_ref_ptr);3261 next_rec_ref_ptr= get_next_rec_ref(next_rec_ref_ptr);
3262 uchar *rec_ptr= next_rec_ref_ptr+rec_fields_offset;3262 uchar *rec_ptr= next_rec_ref_ptr+rec_fields_offset;
32633263
3264 if (join->thd->killed)3264 if (join->thd->get_killed())
3265 {3265 {
3266 /* The user has aborted the execution of the query */3266 /* The user has aborted the execution of the query */
3267 join->thd->send_kill_message();3267 join->thd->send_kill_message();
32683268
=== modified file 'Percona-Server/sql/sql_load.cc'
--- Percona-Server/sql/sql_load.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_load.cc 2013-01-09 13:41:38 +0000
@@ -526,11 +526,11 @@
526 DBUG_EXECUTE_IF("simulate_kill_bug27571",526 DBUG_EXECUTE_IF("simulate_kill_bug27571",
527 {527 {
528 error=1;528 error=1;
529 thd->killed= THD::KILL_QUERY;529 thd->set_killed(THD::KILL_QUERY);
530 };);530 };);
531531
532#ifndef EMBEDDED_LIBRARY532#ifndef EMBEDDED_LIBRARY
533 killed_status= (error == 0) ? THD::NOT_KILLED : thd->killed;533 killed_status= (error == 0) ? THD::NOT_KILLED : thd->get_killed();
534#endif534#endif
535535
536 /*536 /*
@@ -795,7 +795,7 @@
795795
796 while (!read_info.read_fixed_length())796 while (!read_info.read_fixed_length())
797 {797 {
798 if (thd->killed)798 if (thd->get_killed())
799 {799 {
800 thd->send_kill_message();800 thd->send_kill_message();
801 DBUG_RETURN(1);801 DBUG_RETURN(1);
@@ -870,7 +870,7 @@
870 thd->get_stmt_da()->current_row_for_warning());870 thd->get_stmt_da()->current_row_for_warning());
871 }871 }
872872
873 if (thd->killed ||873 if (thd->get_killed() ||
874 fill_record_n_invoke_before_triggers(thd, set_fields, set_values,874 fill_record_n_invoke_before_triggers(thd, set_fields, set_values,
875 ignore_check_option_errors,875 ignore_check_option_errors,
876 table->triggers,876 table->triggers,
@@ -931,7 +931,7 @@
931931
932 for (;;it.rewind())932 for (;;it.rewind())
933 {933 {
934 if (thd->killed)934 if (thd->get_killed())
935 {935 {
936 thd->send_kill_message();936 thd->send_kill_message();
937 DBUG_RETURN(1);937 DBUG_RETURN(1);
@@ -1080,7 +1080,7 @@
1080 }1080 }
1081 }1081 }
10821082
1083 if (thd->killed ||1083 if (thd->get_killed() ||
1084 fill_record_n_invoke_before_triggers(thd, set_fields, set_values,1084 fill_record_n_invoke_before_triggers(thd, set_fields, set_values,
1085 ignore_check_option_errors,1085 ignore_check_option_errors,
1086 table->triggers,1086 table->triggers,
@@ -1112,7 +1112,7 @@
1112 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,1112 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
1113 ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS),1113 ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS),
1114 thd->get_stmt_da()->current_row_for_warning());1114 thd->get_stmt_da()->current_row_for_warning());
1115 if (thd->killed)1115 if (thd->get_killed())
1116 DBUG_RETURN(1);1116 DBUG_RETURN(1);
1117 }1117 }
1118 thd->get_stmt_da()->inc_current_row_for_warning();1118 thd->get_stmt_da()->inc_current_row_for_warning();
@@ -1140,7 +1140,7 @@
11401140
1141 for ( ; ; it.rewind())1141 for ( ; ; it.rewind())
1142 {1142 {
1143 if (thd->killed)1143 if (thd->get_killed())
1144 {1144 {
1145 thd->send_kill_message();1145 thd->send_kill_message();
1146 DBUG_RETURN(1);1146 DBUG_RETURN(1);
@@ -1254,7 +1254,7 @@
1254 }1254 }
1255 }1255 }
12561256
1257 if (thd->killed ||1257 if (thd->get_killed() ||
1258 fill_record_n_invoke_before_triggers(thd, set_fields, set_values,1258 fill_record_n_invoke_before_triggers(thd, set_fields, set_values,
1259 ignore_check_option_errors,1259 ignore_check_option_errors,
1260 table->triggers,1260 table->triggers,
12611261
=== modified file 'Percona-Server/sql/sql_optimizer.cc'
--- Percona-Server/sql/sql_optimizer.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_optimizer.cc 2013-01-09 13:41:38 +0000
@@ -3730,8 +3730,8 @@
3730 if (Optimize_table_order(thd, join, NULL).choose_table_order())3730 if (Optimize_table_order(thd, join, NULL).choose_table_order())
3731 DBUG_RETURN(true);3731 DBUG_RETURN(true);
37323732
3733 DBUG_EXECUTE_IF("bug13820776_1", thd->killed= THD::KILL_QUERY;);3733 DBUG_EXECUTE_IF("bug13820776_1", thd->set_killed(THD::KILL_QUERY););
3734 if (thd->killed || thd->is_error())3734 if (thd->get_killed() || thd->is_error())
3735 DBUG_RETURN(true);3735 DBUG_RETURN(true);
37363736
3737 if (join->decide_subquery_strategy())3737 if (join->decide_subquery_strategy())
37383738
=== modified file 'Percona-Server/sql/sql_parse.cc'
--- Percona-Server/sql/sql_parse.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_parse.cc 2013-01-09 13:41:38 +0000
@@ -942,7 +942,7 @@
942 /*942 /*
943 Synchronization point for testing of KILL_CONNECTION.943 Synchronization point for testing of KILL_CONNECTION.
944 This sync point can wait here, to simulate slow code execution944 This sync point can wait here, to simulate slow code execution
945 between the last test of thd->killed and blocking in read().945 between the last test of thd->get_killed() and blocking in read().
946946
947 The goal of this test is to verify that a connection does not947 The goal of this test is to verify that a connection does not
948 hang, if it is killed at this point of execution.948 hang, if it is killed at this point of execution.
@@ -1311,7 +1311,7 @@
13111311
1312 mysql_parse(thd, thd->query(), thd->query_length(), &parser_state);1312 mysql_parse(thd, thd->query(), thd->query_length(), &parser_state);
13131313
1314 while (!thd->killed && (parser_state.m_lip.found_semicolon != NULL) &&1314 while (!thd->get_killed() && (parser_state.m_lip.found_semicolon != NULL) &&
1315 ! thd->is_error())1315 ! thd->is_error())
1316 {1316 {
1317 /*1317 /*
@@ -1690,7 +1690,7 @@
16901690
1691 /* Finalize server status flags after executing a command. */1691 /* Finalize server status flags after executing a command. */
1692 thd->update_server_status();1692 thd->update_server_status();
1693 if (thd->killed)1693 if (thd->get_killed())
1694 thd->send_kill_message();1694 thd->send_kill_message();
1695 thd->protocol->end_statement();1695 thd->protocol->end_statement();
1696 query_cache_end_of_result(thd);1696 query_cache_end_of_result(thd);
@@ -4179,7 +4179,7 @@
4179 }4179 }
4180 /* Disconnect the current client connection. */4180 /* Disconnect the current client connection. */
4181 if (tx_release)4181 if (tx_release)
4182 thd->killed= THD::KILL_CONNECTION;4182 thd->set_killed(THD::KILL_CONNECTION);
4183 my_ok(thd);4183 my_ok(thd);
4184 break;4184 break;
4185 }4185 }
@@ -4210,7 +4210,7 @@
4210 }4210 }
4211 /* Disconnect the current client connection. */4211 /* Disconnect the current client connection. */
4212 if (tx_release)4212 if (tx_release)
4213 thd->killed= THD::KILL_CONNECTION;4213 thd->set_killed(THD::KILL_CONNECTION);
4214 my_ok(thd);4214 my_ok(thd);
4215 break;4215 break;
4216 }4216 }
@@ -4469,7 +4469,7 @@
4469 }4469 }
4470 else4470 else
4471 {4471 {
4472 DBUG_ASSERT(thd->is_error() || thd->killed);4472 DBUG_ASSERT(thd->is_error() || thd->get_killed());
4473 goto error; // Substatement should already have sent error4473 goto error; // Substatement should already have sent error
4474 }4474 }
4475 }4475 }
@@ -4495,7 +4495,7 @@
4495 /* Conditionally writes to binlog */4495 /* Conditionally writes to binlog */
4496 int sp_result= sp_update_routine(thd, sp_type, lex->spname,4496 int sp_result= sp_update_routine(thd, sp_type, lex->spname,
4497 &lex->sp_chistics);4497 &lex->sp_chistics);
4498 if (thd->killed)4498 if (thd->get_killed())
4499 goto error;4499 goto error;
4500 switch (sp_result)4500 switch (sp_result)
4501 {4501 {
@@ -4808,7 +4808,7 @@
4808 drop_server() can fail without reporting an error4808 drop_server() can fail without reporting an error
4809 due to IF EXISTS clause. In this case, call my_ok().4809 due to IF EXISTS clause. In this case, call my_ok().
4810 */4810 */
4811 if (thd->is_error() || thd->killed)4811 if (thd->is_error() || thd->get_killed())
4812 goto error;4812 goto error;
4813 DBUG_ASSERT(lex->drop_if_exists);4813 DBUG_ASSERT(lex->drop_if_exists);
4814 my_ok(thd, 0);4814 my_ok(thd, 0);
@@ -4883,9 +4883,9 @@
4883 /* report error issued during command execution */4883 /* report error issued during command execution */
4884 if (thd->killed_errno())4884 if (thd->killed_errno())
4885 thd->send_kill_message();4885 thd->send_kill_message();
4886 if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA)4886 if (thd->get_killed() == THD::KILL_QUERY || thd->get_killed() == THD::KILL_BAD_DATA)
4887 {4887 {
4888 thd->killed= THD::NOT_KILLED;4888 thd->set_killed(THD::NOT_KILLED);
4889 thd->mysys_var->abort= 0;4889 thd->mysys_var->abort= 0;
4890 }4890 }
4891 if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR))4891 if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR))
@@ -6096,7 +6096,15 @@
6096 error= 1;6096 error= 1;
6097 }6097 }
6098 else6098 else
6099 error= mysql_execute_command(thd);6099 {
6100 if (thd->variables.sql_timeout)
6101 thd->sql_timeout_expire= my_micro_time() +
6102 (ulonglong)thd->variables.sql_timeout*1000000;
6103
6104 error= mysql_execute_command(thd);
6105
6106 thd->sql_timeout_expire= 0;
6107 }
6100 if (error == 0 &&6108 if (error == 0 &&
6101 thd->variables.gtid_next.type == GTID_GROUP &&6109 thd->variables.gtid_next.type == GTID_GROUP &&
6102 thd->owned_gtid.sidno != 0 &&6110 thd->owned_gtid.sidno != 0 &&
@@ -7009,7 +7017,7 @@
7009 uint error;7017 uint error;
7010 if (!(error= kill_one_thread(thd, id, only_kill_query)))7018 if (!(error= kill_one_thread(thd, id, only_kill_query)))
7011 {7019 {
7012 if (! thd->killed)7020 if (! thd->get_killed())
7013 my_ok(thd);7021 my_ok(thd);
7014 }7022 }
7015 else7023 else
70167024
=== modified file 'Percona-Server/sql/sql_planner.cc'
--- Percona-Server/sql/sql_planner.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/sql/sql_planner.cc 2013-01-09 13:41:38 +0000
@@ -1768,8 +1768,8 @@
1768{1768{
1769 DBUG_ENTER("Optimize_table_order::best_extension_by_limited_search");1769 DBUG_ENTER("Optimize_table_order::best_extension_by_limited_search");
17701770
1771 DBUG_EXECUTE_IF("bug13820776_2", thd->killed= THD::KILL_QUERY;);1771 DBUG_EXECUTE_IF("bug13820776_2", thd->set_killed(THD::KILL_QUERY););
1772 if (thd->killed) // Abort1772 if (thd->get_killed()) // Abort
1773 DBUG_RETURN(true);1773 DBUG_RETURN(true);
1774 Opt_trace_context * const trace= &thd->opt_trace;1774 Opt_trace_context * const trace= &thd->opt_trace;
17751775
17761776
=== modified file 'Percona-Server/sql/sql_prepare.cc'
--- Percona-Server/sql/sql_prepare.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_prepare.cc 2013-01-09 13:41:38 +0000
@@ -3553,7 +3553,7 @@
3553 thd->pop_reprepare_observer();3553 thd->pop_reprepare_observer();
35543554
3555 if ((sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) &&3555 if ((sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) &&
3556 error && !thd->is_fatal_error && !thd->killed &&3556 error && !thd->is_fatal_error && !thd->get_killed() &&
3557 reprepare_observer.is_invalidated() &&3557 reprepare_observer.is_invalidated() &&
3558 reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS)3558 reprepare_attempt++ < MAX_REPREPARE_ATTEMPTS)
3559 {3559 {
35603560
=== modified file 'Percona-Server/sql/sql_reload.cc'
--- Percona-Server/sql/sql_reload.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/sql/sql_reload.cc 2013-01-09 13:41:38 +0000
@@ -50,7 +50,7 @@
5050
51 @return Error status code51 @return Error status code
52 @retval 0 Ok52 @retval 0 Ok
53 @retval !=0 Error; thd->killed is set or thd->is_error() is true53 @retval !=0 Error; thd->get_killed() is set or thd->is_error() is true
54*/54*/
5555
56bool reload_acl_and_cache(THD *thd, unsigned long options,56bool reload_acl_and_cache(THD *thd, unsigned long options,
@@ -340,7 +340,7 @@
340 /*340 /*
341 If the query was killed then this function must fail.341 If the query was killed then this function must fail.
342 */342 */
343 return result || (thd ? thd->killed : 0);343 return result || (thd ? thd->get_killed() : 0);
344}344}
345345
346346
347347
=== modified file 'Percona-Server/sql/sql_servers.cc'
--- Percona-Server/sql/sql_servers.cc 2012-07-30 13:28:51 +0000
+++ Percona-Server/sql/sql_servers.cc 2013-01-09 13:41:38 +0000
@@ -607,7 +607,7 @@
607 }607 }
608608
609 mysql_rwlock_unlock(&THR_LOCK_servers);609 mysql_rwlock_unlock(&THR_LOCK_servers);
610 DBUG_RETURN(error || thd->killed);610 DBUG_RETURN(error || thd->get_killed());
611}611}
612612
613613
@@ -936,7 +936,7 @@
936936
937end:937end:
938 mysql_rwlock_unlock(&THR_LOCK_servers);938 mysql_rwlock_unlock(&THR_LOCK_servers);
939 DBUG_RETURN(error || thd->killed);939 DBUG_RETURN(error || thd->get_killed());
940}940}
941941
942942
@@ -984,7 +984,7 @@
984984
985end:985end:
986 mysql_rwlock_unlock(&THR_LOCK_servers);986 mysql_rwlock_unlock(&THR_LOCK_servers);
987 DBUG_RETURN(error || thd->killed);987 DBUG_RETURN(error || thd->get_killed());
988}988}
989989
990990
991991
=== modified file 'Percona-Server/sql/sql_show.cc'
--- Percona-Server/sql/sql_show.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_show.cc 2013-01-09 13:41:38 +0000
@@ -859,7 +859,7 @@
859 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) ||859 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) ||
860 mysql_handle_derived(thd->lex, &mysql_derived_prepare);860 mysql_handle_derived(thd->lex, &mysql_derived_prepare);
861 thd->pop_internal_handler();861 thd->pop_internal_handler();
862 if (open_error && (thd->killed || thd->is_error()))862 if (open_error && (thd->get_killed() || thd->is_error()))
863 goto exit;863 goto exit;
864 }864 }
865865
@@ -2040,7 +2040,7 @@
2040 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))2040 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
2041 DBUG_VOID_RETURN;2041 DBUG_VOID_RETURN;
20422042
2043 if (!thd->killed)2043 if (!thd->get_killed())
2044 {2044 {
2045 mysql_mutex_lock(&LOCK_thread_count);2045 mysql_mutex_lock(&LOCK_thread_count);
2046 Thread_iterator it= global_thread_list_begin();2046 Thread_iterator it= global_thread_list_begin();
@@ -2076,7 +2076,7 @@
2076 mysql_mutex_lock(&tmp->LOCK_thd_data);2076 mysql_mutex_lock(&tmp->LOCK_thd_data);
2077 if ((mysys_var= tmp->mysys_var))2077 if ((mysys_var= tmp->mysys_var))
2078 mysql_mutex_lock(&mysys_var->mutex);2078 mysql_mutex_lock(&mysys_var->mutex);
2079 thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0);2079 thd_info->proc_info= (char*) (tmp->get_killed() == THD::KILL_CONNECTION? "Killed" : 0);
2080 thd_info->state_info= thread_state_info(tmp);2080 thd_info->state_info= thread_state_info(tmp);
2081 if (mysys_var)2081 if (mysys_var)
2082 mysql_mutex_unlock(&mysys_var->mutex);2082 mysql_mutex_unlock(&mysys_var->mutex);
@@ -2137,7 +2137,7 @@
2137 user= thd->security_ctx->master_access & PROCESS_ACL ?2137 user= thd->security_ctx->master_access & PROCESS_ACL ?
2138 NullS : thd->security_ctx->priv_user;2138 NullS : thd->security_ctx->priv_user;
21392139
2140 if (!thd->killed)2140 if (!thd->get_killed())
2141 {2141 {
2142 mysql_mutex_lock(&LOCK_thread_count);2142 mysql_mutex_lock(&LOCK_thread_count);
2143 Thread_iterator it= global_thread_list_begin();2143 Thread_iterator it= global_thread_list_begin();
@@ -2183,7 +2183,7 @@
2183 if ((mysys_var= tmp->mysys_var))2183 if ((mysys_var= tmp->mysys_var))
2184 mysql_mutex_lock(&mysys_var->mutex);2184 mysql_mutex_lock(&mysys_var->mutex);
2185 /* COMMAND */2185 /* COMMAND */
2186 if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))2186 if ((val= (char *) (tmp->get_killed() == THD::KILL_CONNECTION? "Killed" : 0)))
2187 table->field[4]->store(val, strlen(val), cs);2187 table->field[4]->store(val, strlen(val), cs);
2188 else2188 else
2189 table->field[4]->store(command_name[tmp->get_command()].str,2189 table->field[4]->store(command_name[tmp->get_command()].str,
21902190
=== modified file 'Percona-Server/sql/sql_table.cc'
--- Percona-Server/sql/sql_table.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_table.cc 2013-01-09 13:41:38 +0000
@@ -2335,7 +2335,7 @@
2335 DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,2335 DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
2336 table->table_name,2336 table->table_name,
2337 MDL_EXCLUSIVE));2337 MDL_EXCLUSIVE));
2338 if (thd->killed)2338 if (thd->get_killed())
2339 {2339 {
2340 error= -1;2340 error= -1;
2341 goto err;2341 goto err;
@@ -8513,7 +8513,7 @@
8513 restore_record(to, s->default_values); // Create empty record8513 restore_record(to, s->default_values); // Create empty record
8514 while (!(error=info.read_record(&info)))8514 while (!(error=info.read_record(&info)))
8515 {8515 {
8516 if (thd->killed)8516 if (thd->get_killed())
8517 {8517 {
8518 thd->send_kill_message();8518 thd->send_kill_message();
8519 error= 1;8519 error= 1;
@@ -8760,7 +8760,7 @@
8760 {8760 {
8761 for (;;)8761 for (;;)
8762 {8762 {
8763 if (thd->killed)8763 if (thd->get_killed())
8764 {8764 {
8765 /* 8765 /*
8766 we've been killed; let handler clean up, and remove the 8766 we've been killed; let handler clean up, and remove the
87678767
=== modified file 'Percona-Server/sql/sql_update.cc'
--- Percona-Server/sql/sql_update.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sql_update.cc 2013-01-09 13:41:38 +0000
@@ -622,7 +622,7 @@
622 THD_STAGE_INFO(thd, stage_searching_rows_for_update);622 THD_STAGE_INFO(thd, stage_searching_rows_for_update);
623 ha_rows tmp_limit= limit;623 ha_rows tmp_limit= limit;
624624
625 while (!(error=info.read_record(&info)) && !thd->killed)625 while (!(error=info.read_record(&info)) && !thd->get_killed())
626 {626 {
627 thd->inc_examined_row_count(1);627 thd->inc_examined_row_count(1);
628 bool skip_record= FALSE;628 bool skip_record= FALSE;
@@ -653,7 +653,7 @@
653 else653 else
654 table->file->unlock_row();654 table->file->unlock_row();
655 }655 }
656 if (thd->killed && !error)656 if (thd->get_killed() && !error)
657 error= 1; // Aborted657 error= 1; // Aborted
658 limit= tmp_limit;658 limit= tmp_limit;
659 table->file->try_semi_consistent_read(0);659 table->file->try_semi_consistent_read(0);
@@ -724,7 +724,7 @@
724 check_constant_expressions(values))724 check_constant_expressions(values))
725 read_removal= table->check_read_removal(select->quick->index);725 read_removal= table->check_read_removal(select->quick->index);
726726
727 while (!(error=info.read_record(&info)) && !thd->killed)727 while (!(error=info.read_record(&info)) && !thd->get_killed())
728 {728 {
729 thd->inc_examined_row_count(1);729 thd->inc_examined_row_count(1);
730 bool skip_record;730 bool skip_record;
@@ -897,11 +897,11 @@
897 It's assumed that if an error was set in combination with an effective 897 It's assumed that if an error was set in combination with an effective
898 killed status then the error is due to killing.898 killed status then the error is due to killing.
899 */899 */
900 killed_status= thd->killed; // get the status of the volatile 900 killed_status= thd->get_killed(); // get the status of the volatile
901 // simulated killing after the loop must be ineffective for binlogging901 // simulated killing after the loop must be ineffective for binlogging
902 DBUG_EXECUTE_IF("simulate_kill_bug27571",902 DBUG_EXECUTE_IF("simulate_kill_bug27571",
903 {903 {
904 thd->killed= THD::KILL_QUERY;904 thd->set_killed(THD::KILL_QUERY);
905 };);905 };);
906 error= (killed_status == THD::NOT_KILLED)? error : 1;906 error= (killed_status == THD::NOT_KILLED)? error : 1;
907 907
@@ -2185,7 +2185,7 @@
2185 got caught and if happens later the killed error is written2185 got caught and if happens later the killed error is written
2186 into repl event.2186 into repl event.
2187 */2187 */
2188 int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);2188 int errcode= query_error_code(thd, thd->get_killed() == THD::NOT_KILLED);
2189 /* the error of binary logging is ignored */2189 /* the error of binary logging is ignored */
2190 (void)thd->binlog_query(THD::ROW_QUERY_TYPE,2190 (void)thd->binlog_query(THD::ROW_QUERY_TYPE,
2191 thd->query(), thd->query_length(),2191 thd->query(), thd->query_length(),
@@ -2249,7 +2249,7 @@
22492249
2250 for (;;)2250 for (;;)
2251 {2251 {
2252 if (thd->killed && trans_safe)2252 if (thd->get_killed() && trans_safe)
2253 goto err;2253 goto err;
2254 if ((local_error=tmp_table->file->ha_rnd_next(tmp_table->record[0])))2254 if ((local_error=tmp_table->file->ha_rnd_next(tmp_table->record[0])))
2255 {2255 {
@@ -2389,7 +2389,7 @@
2389 if local_error is not set ON until after do_updates() then2389 if local_error is not set ON until after do_updates() then
2390 later carried out killing should not affect binlogging.2390 later carried out killing should not affect binlogging.
2391 */2391 */
2392 killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed;2392 killed_status= (local_error == 0)? THD::NOT_KILLED : thd->get_killed();
2393 THD_STAGE_INFO(thd, stage_end);2393 THD_STAGE_INFO(thd, stage_end);
23942394
2395 /* We must invalidate the query cache before binlog writing and2395 /* We must invalidate the query cache before binlog writing and
23962396
=== modified file 'Percona-Server/sql/sys_vars.cc'
--- Percona-Server/sql/sys_vars.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/sys_vars.cc 2013-01-09 13:41:38 +0000
@@ -3519,6 +3519,12 @@
3519 SESSION_VAR(group_concat_max_len), CMD_LINE(REQUIRED_ARG),3519 SESSION_VAR(group_concat_max_len), CMD_LINE(REQUIRED_ARG),
3520 VALID_RANGE(4, ULONG_MAX), DEFAULT(1024), BLOCK_SIZE(1));3520 VALID_RANGE(4, ULONG_MAX), DEFAULT(1024), BLOCK_SIZE(1));
35213521
3522static Sys_var_ulong Sys_sql_timeout(
3523 "sql_timeout",
3524 "Timeout in seconds to wait before killing query.",
3525 SESSION_VAR(sql_timeout), CMD_LINE(REQUIRED_ARG),
3526 VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1));
3527
3522static char *glob_hostname_ptr;3528static char *glob_hostname_ptr;
3523static Sys_var_charptr Sys_hostname(3529static Sys_var_charptr Sys_hostname(
3524 "hostname", "Server host name",3530 "hostname", "Server host name",
35253531
=== modified file 'Percona-Server/sql/table.cc'
--- Percona-Server/sql/table.cc 2012-12-04 08:24:59 +0000
+++ Percona-Server/sql/table.cc 2013-01-09 13:41:38 +0000
@@ -3941,7 +3941,7 @@
39413941
3942void TABLE_LIST::hide_view_error(THD *thd)3942void TABLE_LIST::hide_view_error(THD *thd)
3943{3943{
3944 if (thd->killed || thd->get_internal_handler())3944 if (thd->get_killed() || thd->get_internal_handler())
3945 return;3945 return;
3946 /* Hide "Unknown column" or "Unknown function" error */3946 /* Hide "Unknown column" or "Unknown function" error */
3947 DBUG_ASSERT(thd->is_error());3947 DBUG_ASSERT(thd->is_error());
39483948
=== modified file 'Percona-Server/storage/innobase/row/row0mysql.cc'
--- Percona-Server/storage/innobase/row/row0mysql.cc 2012-12-17 22:22:38 +0000
+++ Percona-Server/storage/innobase/row/row0mysql.cc 2013-01-09 13:41:38 +0000
@@ -5062,7 +5062,7 @@
50625062
5063 ret = row_search_for_mysql(buf, PAGE_CUR_G, prebuilt, 0, 0);5063 ret = row_search_for_mysql(buf, PAGE_CUR_G, prebuilt, 0, 0);
5064loop:5064loop:
5065 /* Check thd->killed every 1,000 scanned rows */5065 /* Check thd->get_killed() every 1,000 scanned rows */
5066 if (--cnt == 0) {5066 if (--cnt == 0) {
5067 if (trx_is_interrupted(prebuilt->trx)) {5067 if (trx_is_interrupted(prebuilt->trx)) {
5068 goto func_exit;5068 goto func_exit;
50695069
=== modified file 'Percona-Server/storage/myisam/ha_myisam.cc'
--- Percona-Server/storage/myisam/ha_myisam.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/myisam/ha_myisam.cc 2013-01-09 13:41:38 +0000
@@ -118,7 +118,7 @@
118 THD *thd;118 THD *thd;
119 thd= current_thd;119 thd= current_thd;
120 prev_info= thd_proc_info(thd, info);120 prev_info= thd_proc_info(thd, info);
121 while(!thd->killed)121 while(!thd->get_killed())
122 my_sleep(1000);122 my_sleep(1000);
123 DBUG_PRINT("info", ("Exit debug_wait_for_kill"));123 DBUG_PRINT("info", ("Exit debug_wait_for_kill"));
124 thd_proc_info(thd, prev_info);124 thd_proc_info(thd, prev_info);
@@ -562,10 +562,10 @@
562562
563extern "C" {563extern "C" {
564564
565volatile int *killed_ptr(MI_CHECK *param)565int killed_status(MI_CHECK *param)
566{566{
567 /* In theory Unsafe conversion, but should be ok for now */567 /* In theory Unsafe conversion, but should be ok for now */
568 return (int*) &(((THD *)(param->thd))->killed);568 return (int) (((THD *)(param->thd))->get_killed());
569}569}
570570
571void mi_check_print_error(MI_CHECK *param, const char *fmt,...)571void mi_check_print_error(MI_CHECK *param, const char *fmt,...)
@@ -902,7 +902,7 @@
902 HA_STATUS_CONST);902 HA_STATUS_CONST);
903 }903 }
904 }904 }
905 else if (!mi_is_crashed(file) && !thd->killed)905 else if (!mi_is_crashed(file) && !thd->get_killed())
906 {906 {
907 mi_mark_crashed(file);907 mi_mark_crashed(file);
908 file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;908 file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
@@ -945,7 +945,7 @@
945 error=update_state_info(&param,file,UPDATE_STAT);945 error=update_state_info(&param,file,UPDATE_STAT);
946 mysql_mutex_unlock(&share->intern_lock);946 mysql_mutex_unlock(&share->intern_lock);
947 }947 }
948 else if (!mi_is_crashed(file) && !thd->killed)948 else if (!mi_is_crashed(file) && !thd->get_killed())
949 mi_mark_crashed(file);949 mi_mark_crashed(file);
950 return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;950 return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
951}951}
@@ -1537,7 +1537,7 @@
1537 */1537 */
1538 1538
1539 if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) && 1539 if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) &&
1540 current_thd->killed)1540 current_thd->get_killed())
1541 {1541 {
1542 delete_all_rows();1542 delete_all_rows();
1543 /* not crashed, despite being killed during repair */1543 /* not crashed, despite being killed during repair */
15441544
=== modified file 'Percona-Server/storage/myisam/mi_check.c'
--- Percona-Server/storage/myisam/mi_check.c 2012-09-12 14:19:10 +0000
+++ Percona-Server/storage/myisam/mi_check.c 2013-01-09 13:41:38 +0000
@@ -164,7 +164,7 @@
164 empty=0;164 empty=0;
165 for (i= info->state->del ; i > 0L && next_link != HA_OFFSET_ERROR ; i--)165 for (i= info->state->del ; i > 0L && next_link != HA_OFFSET_ERROR ; i--)
166 {166 {
167 if (*killed_ptr(param))167 if (killed_status(param))
168 DBUG_RETURN(1);168 DBUG_RETURN(1);
169 if (test_flag & T_VERBOSE)169 if (test_flag & T_VERBOSE)
170 printf(" %9s",llstr(next_link,buff));170 printf(" %9s",llstr(next_link,buff));
@@ -259,7 +259,7 @@
259 records= (ha_rows) (info->state->key_file_length / block_size);259 records= (ha_rows) (info->state->key_file_length / block_size);
260 while (next_link != HA_OFFSET_ERROR && records > 0)260 while (next_link != HA_OFFSET_ERROR && records > 0)
261 {261 {
262 if (*killed_ptr(param))262 if (killed_status(param))
263 DBUG_RETURN(1);263 DBUG_RETURN(1);
264 if (param->testflag & T_VERBOSE)264 if (param->testflag & T_VERBOSE)
265 printf("%16s",llstr(next_link,llbuff));265 printf("%16s",llstr(next_link,llbuff));
@@ -773,7 +773,7 @@
773 }773 }
774 for ( ;; )774 for ( ;; )
775 {775 {
776 if (*killed_ptr(param))776 if (killed_status(param))
777 goto err;777 goto err;
778 memcpy((char*) info->lastkey,(char*) key,key_length);778 memcpy((char*) info->lastkey,(char*) key,key_length);
779 info->lastkey_length=key_length;779 info->lastkey_length=key_length;
@@ -985,7 +985,7 @@
985 memset(key_checksum, 0, info->s->base.keys * sizeof(key_checksum[0]));985 memset(key_checksum, 0, info->s->base.keys * sizeof(key_checksum[0]));
986 while (pos < info->state->data_file_length)986 while (pos < info->state->data_file_length)
987 {987 {
988 if (*killed_ptr(param))988 if (killed_status(param))
989 goto err2;989 goto err2;
990 switch (info->s->data_file_type) {990 switch (info->s->data_file_type) {
991 case STATIC_RECORD:991 case STATIC_RECORD:
@@ -3253,7 +3253,7 @@
3253 char llbuff[22],llbuff2[22];3253 char llbuff[22],llbuff2[22];
3254 DBUG_ENTER("sort_get_next_record");3254 DBUG_ENTER("sort_get_next_record");
32553255
3256 if (*killed_ptr(param))3256 if (killed_status(param))
3257 DBUG_RETURN(1);3257 DBUG_RETURN(1);
32583258
3259 switch (share->data_file_type) {3259 switch (share->data_file_type) {
32603260
=== modified file 'Percona-Server/storage/myisam/myisamchk.c'
--- Percona-Server/storage/myisam/myisamchk.c 2012-08-22 01:40:20 +0000
+++ Percona-Server/storage/myisam/myisamchk.c 2013-01-09 13:41:38 +0000
@@ -1702,11 +1702,9 @@
1702 sorting1702 sorting
1703*/1703*/
17041704
1705static int not_killed= 0;1705int killed_status(MI_CHECK *param __attribute__((unused)))
1706
1707volatile int *killed_ptr(MI_CHECK *param __attribute__((unused)))
1708{1706{
1709 return &not_killed; /* always NULL */1707 return 0; /* always NULL */
1710}1708}
17111709
1712 /* print warnings and errors */1710 /* print warnings and errors */
17131711
=== modified file 'Percona-Server/storage/myisam/myisamdef.h'
--- Percona-Server/storage/myisam/myisamdef.h 2012-03-06 14:29:42 +0000
+++ Percona-Server/storage/myisam/myisamdef.h 2013-01-09 13:41:38 +0000
@@ -769,7 +769,7 @@
769int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record);769int mi_check_index_cond(register MI_INFO *info, uint keynr, uchar *record);
770770
771 /* Functions needed by mi_check */771 /* Functions needed by mi_check */
772volatile int *killed_ptr(MI_CHECK *param);772int killed_status(MI_CHECK *param);
773void mi_check_print_error(MI_CHECK *param, const char *fmt,...);773void mi_check_print_error(MI_CHECK *param, const char *fmt,...);
774void mi_check_print_warning(MI_CHECK *param, const char *fmt,...);774void mi_check_print_warning(MI_CHECK *param, const char *fmt,...);
775void mi_check_print_info(MI_CHECK *param, const char *fmt,...);775void mi_check_print_info(MI_CHECK *param, const char *fmt,...);
776776
=== modified file 'Percona-Server/storage/myisam/sort.c'
--- Percona-Server/storage/myisam/sort.c 2012-03-06 14:29:42 +0000
+++ Percona-Server/storage/myisam/sort.c 2013-01-09 13:41:38 +0000
@@ -910,7 +910,7 @@
910 uchar *strpos;910 uchar *strpos;
911 BUFFPEK *buffpek,**refpek;911 BUFFPEK *buffpek,**refpek;
912 QUEUE queue;912 QUEUE queue;
913 volatile int *killed= killed_ptr(info->sort_info->param);913 int killed= killed_status(info->sort_info->param);
914 DBUG_ENTER("merge_buffers");914 DBUG_ENTER("merge_buffers");
915915
916 count=error=0;916 count=error=0;
@@ -943,7 +943,7 @@
943 {943 {
944 for (;;)944 for (;;)
945 {945 {
946 if (*killed)946 if (killed)
947 {947 {
948 error=1; goto err;948 error=1; goto err;
949 }949 }

Subscribers

People subscribed via source and target branches