List:Commits« Previous MessageNext Message »
From:ahristov Date:March 7 2006 4:46pm
Subject:bk commit into 5.1 tree (andrey:1.2164) BUG#17815
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2164 06/03/07 17:45:56 andrey@lmy004. +5 -0
  fix for bug #17815 Scheduler may not see a change of an event

  sql/event_executor.cc
    1.42 06/03/07 17:45:48 andrey@lmy004. +8 -7
    don't check modified which has seconds resolution bug modified_w_usec

  sql/event.h
    1.27 06/03/07 17:45:48 andrey@lmy004. +4 -1
    add a new member variable modified_w_usec which has
    higher resolution than modified

  sql/event.cc
    1.38 06/03/07 17:45:48 andrey@lmy004. +1 -1
    set modified_w_usec to value

  mysql-test/t/events_bugs.test
    1.2 06/03/07 17:45:48 andrey@lmy004. +19 -0
    add test for bug #17815 Scheduler may not see a change of an event

  mysql-test/r/events_bugs.result
    1.3 06/03/07 17:45:48 andrey@lmy004. +13 -0
    update result

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	andrey
# Host:	lmy004.
# Root:	/work/mysql-5.1-bug17815

--- 1.2/mysql-test/r/events_bugs.result	2006-02-21 02:40:15 +01:00
+++ 1.3/mysql-test/r/events_bugs.result	2006-03-07 17:45:48 +01:00
@@ -1,5 +1,18 @@
 create database if not exists events_test;
 use events_test;
+create table t17815(a int);
+CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO t17815 VALUES (1);
+set global event_scheduler=1;
+SELECT COUNT(*) FROM t17815;
+COUNT(*)
+1
+ALTER EVENT long_event ON SCHEDULE EVERY 1 SECOND;
+"We should have at least 2 rows -> the change has been sought"
+SELECT IF(COUNT(*)>1, 'OK','ERROR') FROM t17815;
+IF(COUNT(*)>1, 'OK','ERROR')
+OK
+DROP EVENT long_event;
+set global event_scheduler=0;
 set global event_scheduler=0;
 "Wait a bit to settle down"
 delete from mysql.event;

--- 1.1/mysql-test/t/events_bugs.test	2006-02-20 23:52:12 +01:00
+++ 1.2/mysql-test/t/events_bugs.test	2006-03-07 17:45:48 +01:00
@@ -1,6 +1,25 @@
 create database if not exists events_test;
 use events_test;
 #
+# START - BUG#17815: Scheduler may not see a change of an event
+#
+create table t17815(a int);
+CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO t17815 VALUES (1);
+set global event_scheduler=1;
+--sleep 2
+SELECT COUNT(*) FROM t17815;
+ALTER EVENT long_event ON SCHEDULE EVERY 1 SECOND;
+--echo "We should have at least 2 rows -> the change has been sought"
+--sleep 1
+SELECT IF(COUNT(*)>1, 'OK','ERROR') FROM t17815;
+DROP EVENT long_event;
+set global event_scheduler=0;
+--sleep 1
+#
+# END   - BUG#17815: Scheduler may not see a change of an event
+#
+
+#
 # Start - 16407: Events: Changes in sql_mode won't be taken into account
 #
 set global event_scheduler=0;

--- 1.37/sql/event.cc	2006-02-28 20:32:30 +01:00
+++ 1.38/sql/event.cc	2006-03-07 17:45:48 +01:00
@@ -1058,7 +1058,7 @@ evex_load_and_compile_event(THD * thd, s
   ett->compute_next_execution_time();
   if (use_lock)
     VOID(pthread_mutex_lock(&LOCK_event_arrays));
-
+  ett->modified_w_usec= my_getsystime();
   evex_queue_insert(&EVEX_EQ_NAME, (EVEX_PTOQEL) ett);
 
   /*

--- 1.26/sql/event.h	2006-02-28 18:33:25 +01:00
+++ 1.27/sql/event.h	2006-03-07 17:45:48 +01:00
@@ -112,6 +112,8 @@ public:
 
   ulonglong created;
   ulonglong modified;
+  ulonglong modified_w_usec;
+
   enum enum_event_on_completion on_completion;
   enum enum_event_status status;
   sp_head *sphead;
@@ -125,7 +127,8 @@ public:
   Event_timed():in_spawned_thread(0),locked_by_thread_id(0),
                 running(0), status_changed(false),
                 last_executed_changed(false), expression(0), created(0),
-                modified(0), on_completion(MYSQL_EVENT_ON_COMPLETION_DROP),
+                modified(0), modified_w_usec(0),
+                on_completion(MYSQL_EVENT_ON_COMPLETION_DROP),
                 status(MYSQL_EVENT_ENABLED), sphead(0), sql_mode(0), 
                 body_begin(0), dropped(false),
                 free_sphead_on_delete(true), flags(0)

--- 1.41/sql/event_executor.cc	2006-03-01 04:21:57 +01:00
+++ 1.42/sql/event_executor.cc	2006-03-07 17:45:48 +01:00
@@ -354,7 +354,7 @@ executor_wait_till_next_event_exec(THD *
   DBUG_PRINT("evex main thread",("unlocked LOCK_event_arrays"));
   if (t2sleep > 0)
   {
-    ulonglong modified= et->modified;
+    ulonglong modified= et->modified_w_usec;
     /*
       We sleep t2sleep seconds but we check every second whether this thread
       has been killed, or there is a new candidate
@@ -362,15 +362,16 @@ executor_wait_till_next_event_exec(THD *
     while (t2sleep-- && !thd->killed && event_executor_running_global_var &&
            evex_queue_num_elements(EVEX_EQ_NAME) &&
            (evex_queue_first_element(&EVEX_EQ_NAME, Event_timed*) == et &&
-            evex_queue_first_element(&EVEX_EQ_NAME, Event_timed*)->modified ==
-             modified))
+            evex_queue_first_element(&EVEX_EQ_NAME,
+                                     Event_timed*)->modified_w_usec==modified))
     {
       DBUG_PRINT("evex main thread",("will sleep a bit more."));
       my_sleep(1000000);
     }
     DBUG_PRINT("info",("saved_modified=%llu current=%llu", modified,
                evex_queue_num_elements(EVEX_EQ_NAME)? 
-               evex_queue_first_element(&EVEX_EQ_NAME, Event_timed*)->modified:
+               evex_queue_first_element(&EVEX_EQ_NAME,
+                                        Event_timed*)->modified_w_usec:
                (ulonglong)~0));
   }
 
@@ -859,11 +860,11 @@ evex_load_events_from_db(THD *thd)
       continue;
     }
     
+    et->modified_w_usec= my_getsystime();
     DBUG_PRINT("evex_load_events_from_db", ("Adding to the exec list."));
-
     evex_queue_insert(&EVEX_EQ_NAME, (EVEX_PTOQEL) et);
-    DBUG_PRINT("evex_load_events_from_db", ("%p %*s",
-                et, et->name.length,et->name.str));
+    DBUG_PRINT("evex_load_events_from_db", ("%p %*s stamp=%llu",
+               et, et->name.length, et->name.str, et->modified_w_usec));
     count++;
   }
 
Thread
bk commit into 5.1 tree (andrey:1.2164) BUG#17815ahristov7 Mar