summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@oracle.com>2010-10-22 09:58:09 -0200
committerDavi Arnaut <davi.arnaut@oracle.com>2010-10-22 09:58:09 -0200
commit2881b8014ca7101684358b25aaf54784c7f43613 (patch)
tree4571f70663dd1d045d339716fc55ff6c809fec4a /sql/sql_select.cc
parenta776e5f3d297f45d63f48ad919ccd46307cddb30 (diff)
downloadmariadb-git-2881b8014ca7101684358b25aaf54784c7f43613.tar.gz
Bug#37780: Make KILL reliable (main.kill fails randomly)
- A prerequisite cleanup patch for making KILL reliable. The test case main.kill did not work reliably. The following problems have been identified: 1. A kill signal could go lost if it came in, short before a thread went reading on the client connection. 2. A kill signal could go lost if it came in, short before a thread went waiting on a condition variable. These problems have been solved as follows. Please see also added code comments for more details. 1. There is no safe way to detect, when a thread enters the blocking state of a read(2) or recv(2) system call, where it can be interrupted by a signal. Hence it is not possible to wait for the right moment to send a kill signal. It has been decided, not to fix it in the code. Instead, the test case repeats the KILL statement until the connection terminates. 2. Before waiting on a condition variable, we register it together with a synchronizating mutex in THD::mysys_var. After this, we need to test THD::killed again. At some places we did only test it in a loop condition before the registration. When THD::killed had been set between this test and the registration, we entered waiting without noticing the killed flag. Additional checks ahve been introduced where required. In addition to the above, a re-write of the main.kill test case has been done. All sleeps have been replaced by Debug Sync Facility synchronization. A couple of sync points have been added to the server code. To avoid further problems, if the test case fails in spite of the fixes, the test case has been added to the "experimental" list for now. - Most of the work on this patch is authored by Ingo Struewing mysql-test/t/kill.test: Re-wrote test case to use Debug Sync points instead of sleeps sql/event_queue.cc: Fixed kill detection in Event_queue::cond_wait() by adding a check after enter_cond(). sql/lock.cc: Moved Debug Sync points behind enter_cond(). Fixed comments. sql/slave.cc: Fixed kill detection in start_slave_thread() by adding a check after enter_cond(). sql/sql_class.cc: Swapped order of kill and close in THD::awake(). Added comments. sql/sql_class.h: Added a comment to THD::killed. sql/sql_parse.cc: Added a sync point in do_command(). sql/sql_select.cc: Added a sync point in JOIN::optimize().
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2a2fe3eb36f..d9fefe35bd8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -47,6 +47,7 @@
#include "records.h" // init_read_record, end_read_record
#include "filesort.h" // filesort_free_buffers
#include "sql_union.h" // mysql_union
+#include "debug_sync.h" // DEBUG_SYNC
#include <m_ctype.h>
#include <my_bit.h>
#include <hash.h>
@@ -852,6 +853,7 @@ JOIN::optimize()
if (optimized)
DBUG_RETURN(0);
optimized= 1;
+ DEBUG_SYNC(thd, "before_join_optimize");
thd_proc_info(thd, "optimizing");
row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :