#At file:///export/home/x/mysql-5.5-runtime-bug44171/ based on revid:jon.hauglid@stripped
3122 Jon Olav Hauglid 2010-08-26
Bug #44171 KILL ALTER EVENT can crash the server
This assert could be triggered if ALTER EVENT failed to load the
event after altering it. Failing to load the event could for
example happen because of KILL QUERY.
The assert tested that the result of a failed load_named_event()
was OP_LOAD_ERROR. However since load_named_event() returns bool,
this assert did not make any sense. This patch therefore removes
the assert, fixing the problem. The patch also removes
enum_events_error_code since it was unused.
Test case added to events_sync.test.
added:
mysql-test/r/events_sync.result
mysql-test/t/events_sync-master.opt
mysql-test/t/events_sync.test
modified:
sql/events.cc
sql/events.h
=== added file 'mysql-test/r/events_sync.result'
--- a/mysql-test/r/events_sync.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/events_sync.result 2010-08-26 08:28:57 +0000
@@ -0,0 +1,19 @@
+#
+# Bug#44171 KILL ALTER EVENT can crash the server
+#
+DROP EVENT IF EXISTS e1;
+# Connection con1
+CREATE EVENT e1
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
+DO INSERT INTO t1 VALUES (1);
+SET DEBUG_SYNC= 'before_update_event_load SIGNAL waiting WAIT_FOR killed';
+# Sending:
+ALTER EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 DAY;
+# Connection default
+SET DEBUG_SYNC='now WAIT_FOR waiting';
+SET DEBUG_SYNC= 'now SIGNAL killed';
+# Connection con1
+ERROR 70100: Query execution was interrupted
+# Connection default
+DROP EVENT e1;
+SET DEBUG_SYNC= 'RESET';
=== added file 'mysql-test/t/events_sync-master.opt'
--- a/mysql-test/t/events_sync-master.opt 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/events_sync-master.opt 2010-08-26 08:28:57 +0000
@@ -0,0 +1 @@
+--event-scheduler
=== added file 'mysql-test/t/events_sync.test'
--- a/mysql-test/t/events_sync.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/events_sync.test 2010-08-26 08:28:57 +0000
@@ -0,0 +1,57 @@
+#
+# Event tests that require sync points
+#
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+# Check that the event_scheduler is really running
+--source include/running_event_scheduler.inc
+
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+
+--echo #
+--echo # Bug#44171 KILL ALTER EVENT can crash the server
+--echo #
+
+--disable_warnings
+DROP EVENT IF EXISTS e1;
+--enable_warnings
+
+--echo # Connection con1
+connect (con1, localhost, root);
+let $connection_id= `SELECT CONNECTION_ID()`;
+
+CREATE EVENT e1
+ ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
+ DO INSERT INTO t1 VALUES (1);
+
+SET DEBUG_SYNC= 'before_update_event_load SIGNAL waiting WAIT_FOR killed';
+--echo # Sending:
+--send ALTER EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 DAY
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR waiting';
+# kill the query that is waiting
+--disable_query_log
+--eval KILL QUERY $connection_id
+--enable_query_log
+SET DEBUG_SYNC= 'now SIGNAL killed';
+
+--echo # Connection con1
+connection con1;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo # Connection default
+connection default;
+DROP EVENT e1;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+
+
+# Check that all connections opened by test cases in this file are really
+# gone so execution of other tests won't be affected by their presence.
+--source include/wait_until_count_sessions.inc
=== modified file 'sql/events.cc'
--- a/sql/events.cc 2010-08-18 11:29:04 +0000
+++ b/sql/events.cc 2010-08-26 08:28:57 +0000
@@ -30,6 +30,7 @@
#include "event_scheduler.h"
#include "sp_head.h" // for Stored_program_creation_ctx
#include "set_var.h"
+#include "debug_sync.h"
/**
@addtogroup Event_Scheduler
@@ -480,15 +481,13 @@ Events::update_event(THD *thd, Event_par
{
LEX_STRING dbname= new_dbname ? *new_dbname : parse_data->dbname;
LEX_STRING name= new_name ? *new_name : parse_data->name;
+ DEBUG_SYNC(thd, "before_update_event_load");
if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM
else if ((ret= db_repository->load_named_event(thd, dbname, name,
new_element)))
- {
- DBUG_ASSERT(ret == OP_LOAD_ERROR);
delete new_element;
- }
else
{
/*
=== modified file 'sql/events.h'
--- a/sql/events.h 2010-08-05 12:34:19 +0000
+++ b/sql/events.h 2010-08-26 08:28:57 +0000
@@ -44,19 +44,6 @@ class THD;
typedef class Item COND;
typedef struct charset_info_st CHARSET_INFO;
-/* Return codes */
-enum enum_events_error_code
-{
- OP_OK= 0,
- OP_NOT_RUNNING,
- OP_CANT_KILL,
- OP_CANT_INIT,
- OP_DISABLED_EVENT,
- OP_LOAD_ERROR,
- OP_ALREADY_EXISTS
-};
-
-
int
sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20100826082857-d9grzlnnjqr5m23n.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5-runtime branch (jon.hauglid:3122) Bug#44171 | Jon Olav Hauglid | 26 Aug |