List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:October 16 2007 10:41am
Subject:bk commit into 5.1 tree (anozdrin:1.2600) BUG#31111
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of alik. When alik 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@stripped, 2007-10-16 14:41:47+04:00, anozdrin@station. +7 -0
  Patch for BUG#31111: --read-only crashes MySQL (events fail to load).
  
  There actually were several problems here:
    - wrong lock type was acquired before reading mysql.event table;
    - Security_context::master_access attribute was not properly
      initialized in Security_context::init(), which led to differences
      in behavior with and without debug configure options.
    - if the server failed to load events from mysql.event, it:
      - forgot to close the mysql.event table, that led to the coredump,
        described in the bug report;
      - did not deinitialize the replication module, that lead to
        memory-lost warning on exit. 
  
  The patch is to fix all these problems:
    - Use READ-lock when loading events from the mysql.event table;
    - Initialize Security_context::master_access;
    - Close the mysql.event table in case something went wrong;
    - Deinitialize the replication module on exit.

  mysql-test/r/bug31111.result@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +3 -0
    Result file.

  mysql-test/r/bug31111.result@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +0 -0

  mysql-test/t/bug31111-master.opt@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +1 -0
    A test case for BUG#31111.

  mysql-test/t/bug31111-master.opt@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +0 -0

  mysql-test/t/bug31111.test@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +8 -0
    A test case for BUG#31111.

  mysql-test/t/bug31111.test@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +0 -0

  sql/event_db_repository.cc@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +6 -0
    Close tables if something went wrong in simple_open_n_lock_tables().

  sql/events.cc@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +1 -1
    Use READ-lock for loading events.

  sql/mysqld.cc@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +3 -0
    If something went wrong with event loading, we the replication
    module should be deinitialized prior to general exit procedure.

  sql/sql_class.cc@stripped, 2007-10-16 14:41:45+04:00, anozdrin@station. +1 -0
    Initialize Security_context::master_acces.

diff -Nrup a/mysql-test/r/bug31111.result b/mysql-test/r/bug31111.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/bug31111.result	2007-10-16 14:41:45 +04:00
@@ -0,0 +1,3 @@
+SELECT @@global.read_only;
+@@global.read_only
+1
diff -Nrup a/mysql-test/t/bug31111-master.opt b/mysql-test/t/bug31111-master.opt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/bug31111-master.opt	2007-10-16 14:41:45 +04:00
@@ -0,0 +1 @@
+--read-only
diff -Nrup a/mysql-test/t/bug31111.test b/mysql-test/t/bug31111.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/bug31111.test	2007-10-16 14:41:45 +04:00
@@ -0,0 +1,8 @@
+#
+# BUG#31111: --read-only crashes MySQL (events fail to load).
+#
+# It actually does not matter what SQL statements are here. The thing is being
+# tested is that the server is able to start.
+#
+
+SELECT @@global.read_only;
diff -Nrup a/sql/event_db_repository.cc b/sql/event_db_repository.cc
--- a/sql/event_db_repository.cc	2007-08-25 12:43:10 +04:00
+++ b/sql/event_db_repository.cc	2007-10-16 14:41:45 +04:00
@@ -525,6 +525,9 @@ Event_db_repository::fill_schema_events(
   - whether this open mode would work under LOCK TABLES, or inside a
   stored function or trigger.
 
+  Note, if the table can not be open, this operation will clean out all
+  table-related objects from the memory.
+
   @param[in]  thd  Thread context
   @param[in]  lock_type  How to lock the table
   @param[out] table  We will store the open table here
@@ -544,7 +547,10 @@ Event_db_repository::open_event_table(TH
   tables.init_one_table("mysql", "event", lock_type);
 
   if (simple_open_n_lock_tables(thd, &tables))
+  {
+    close_thread_tables(thd, FALSE, FALSE);
     DBUG_RETURN(TRUE);
+  }
 
   *table= tables.table;
   tables.table->use_all_columns();
diff -Nrup a/sql/events.cc b/sql/events.cc
--- a/sql/events.cc	2007-08-15 19:08:40 +04:00
+++ b/sql/events.cc	2007-10-16 14:41:45 +04:00
@@ -1128,7 +1128,7 @@ Events::load_events_from_db(THD *thd)
   DBUG_ENTER("Events::load_events_from_db");
   DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
 
-  if (db_repository->open_event_table(thd, TL_WRITE, &table))
+  if (db_repository->open_event_table(thd, TL_READ, &table))
   {
     sql_print_error("Event Scheduler: Failed to open table mysql.event");
     DBUG_RETURN(TRUE);
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2007-08-28 11:02:53 +04:00
+++ b/sql/mysqld.cc	2007-10-16 14:41:45 +04:00
@@ -3930,7 +3930,10 @@ we force server id to 2, but this MySQL 
   create_maintenance_thread();
 
   if (Events::init(opt_noacl))
+  {
+    end_slave();
     unireg_abort(1);
+  }
 
   sql_print_information(ER(ER_STARTUP),my_progname,server_version,
                         ((unix_sock == INVALID_SOCKET) ? (char*) ""
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2007-10-15 16:42:39 +04:00
+++ b/sql/sql_class.cc	2007-10-16 14:41:45 +04:00
@@ -2404,6 +2404,7 @@ void Security_context::init()
   host= user= priv_user= ip= 0;
   host_or_ip= "connecting host";
   priv_host[0]= '\0';
+  master_access= 0;
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   db_access= NO_ACCESS;
 #endif
Thread
bk commit into 5.1 tree (anozdrin:1.2600) BUG#31111Alexander Nozdrin16 Oct