List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:January 26 2012 6:31am
Subject:bzr push into mysql-trunk branch (chris.powers:3790)
View as plain text  
 3790 Christopher Powers	2012-01-26 [merge]
      local merge

    modified:
      mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
      mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
      storage/innobase/handler/ha_innodb.cc
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2012-01-25 10:07:23 +0000
+++ b/sql/mysqld.cc	2012-01-25 22:37:55 +0000
@@ -1528,8 +1528,8 @@ static void mysqld_exit(int exit_code)
 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
   /*
     Bug#56666 needs to be fixed before calling:
-    shutdown_performance_schema();
   */
+    shutdown_performance_schema();
 #endif
   my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
   exit(exit_code); /* purecov: inspected */

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2012-01-24 23:42:36 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2012-01-25 22:37:55 +0000
@@ -47,7 +47,13 @@
 */
 my_bool pfs_enabled= TRUE;
 
-DYNAMIC_ARRAY pfs_instr_init_array;
+/**
+  PFS_INSTRUMENT option settings array and associated state variable to
+  serialize access during shutdown.
+ */
+DYNAMIC_ARRAY pfs_instr_config_array;
+int pfs_instr_config_state= PFS_INSTR_CONFIG_NOT_INITIALIZED;
+
 static void configure_instr_class(PFS_instr_class *entry);
 
 static void init_instr_class(PFS_instr_class *klass,
@@ -619,10 +625,10 @@ static void configure_instr_class(PFS_in
 {
   uint match_length= 0; /* length of matching pattern */
 
-  for (uint i= 0; i < pfs_instr_init_array.elements; i++)
+  for (uint i= 0; i < pfs_instr_config_array.elements; i++)
   {
-    PFS_instr_init* e;
-    get_dynamic(&pfs_instr_init_array, (uchar*)&e, i);
+    PFS_instr_config* e;
+    get_dynamic(&pfs_instr_config_array, (uchar*)&e, i);
 
     /**
       Compare class name to all configuration entries. In case of multiple

=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h	2012-01-24 23:42:36 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2012-01-25 22:37:55 +0000
@@ -87,7 +87,7 @@ enum PFS_class_type
 };
 
 /** User-defined instrument configuration. */
-struct PFS_instr_init
+struct PFS_instr_config
 {
   /* Instrument name. */
   char *m_name;
@@ -99,7 +99,12 @@ struct PFS_instr_init
   bool m_timed;
 };
 
-extern DYNAMIC_ARRAY pfs_instr_init_array;
+extern DYNAMIC_ARRAY pfs_instr_config_array;
+extern int pfs_instr_config_state;
+
+static const int PFS_INSTR_CONFIG_NOT_INITIALIZED= 0;
+static const int PFS_INSTR_CONFIG_ALLOCATED= 1;
+static const int PFS_INSTR_CONFIG_DEALLOCATED= 2;
 
 struct PFS_thread;
 

=== modified file 'storage/perfschema/pfs_server.cc'
--- a/storage/perfschema/pfs_server.cc	2012-01-24 23:42:36 +0000
+++ b/storage/perfschema/pfs_server.cc	2012-01-25 22:37:55 +0000
@@ -46,6 +46,7 @@ static void destroy_pfs_thread(void *key
 C_MODE_END
 
 static void cleanup_performance_schema(void);
+void cleanup_instrument_config(void);
 
 struct PSI_bootstrap*
 initialize_performance_schema(const PFS_global_param *param)
@@ -65,6 +66,7 @@ initialize_performance_schema(const PFS_
 
   init_timers();
   PFS_atomic::init();
+
   init_event_name_sizing(param);
   register_global_classes();
 
@@ -150,6 +152,8 @@ static void destroy_pfs_thread(void *key
 
 static void cleanup_performance_schema(void)
 {
+  cleanup_instrument_config();
+/*  Disabled: Bug#5666
   cleanup_instruments();
   cleanup_sync_class();
   cleanup_thread_class();
@@ -174,12 +178,14 @@ static void cleanup_performance_schema(v
   cleanup_account();
   cleanup_account_hash();
   PFS_atomic::cleanup();
+*/
 }
 
 void shutdown_performance_schema(void)
 {
   pfs_initialized= false;
   cleanup_performance_schema();
+#if 0
   /*
     Be careful to not delete un-initialized keys,
     this would affect key 0, which is THR_KEY_mysys,
@@ -190,6 +196,7 @@ void shutdown_performance_schema(void)
     pthread_key_delete(THR_PFS);
     THR_PFS_initialized= false;
   }
+#endif
 }
 
 /**
@@ -198,7 +205,22 @@ void shutdown_performance_schema(void)
 */
 void init_pfs_instrument_array()
 {
-  my_init_dynamic_array(&pfs_instr_init_array, sizeof(PFS_instr_init*), 10, 10);
+  my_init_dynamic_array(&pfs_instr_config_array, sizeof(PFS_instr_config*), 10, 10);
+  pfs_instr_config_state=  PFS_INSTR_CONFIG_ALLOCATED;
+}
+
+/**
+  Deallocate the PFS_INSTRUMENT array. Use an atomic compare-and-swap to ensure
+  that it is deallocated only once in the chaotic environment of server shutdown.
+*/
+void cleanup_instrument_config()
+{
+  int desired_state= PFS_INSTR_CONFIG_ALLOCATED;
+  
+  if (my_atomic_load32(&pfs_instr_config_state) == PFS_INSTR_CONFIG_ALLOCATED)
+    /* Ignore if another thread has already deallocated the array */
+    if (my_atomic_cas32(&pfs_instr_config_state, &desired_state, PFS_INSTR_CONFIG_DEALLOCATED))
+      delete_dynamic(&pfs_instr_config_array);
 }
 
 /**
@@ -217,12 +239,12 @@ int add_pfs_instr_to_array(const char* n
   int value_length= strlen(value);
 
   /* Allocate structure plus string buffers plus null terminators */
-  PFS_instr_init* e = (PFS_instr_init*)my_malloc(sizeof(PFS_instr_init)
+  PFS_instr_config* e = (PFS_instr_config*)my_malloc(sizeof(PFS_instr_config)
                        + name_length + 1 + value_length + 1, MYF(MY_WME));
   if (!e) return 1;
   
   /* Copy the instrument name */
-  e->m_name= (char*)e + sizeof(PFS_instr_init);
+  e->m_name= (char*)e + sizeof(PFS_instr_config);
   memcpy(e->m_name, name, name_length);
   e->m_name_length= name_length;
   e->m_name[name_length]= '\0';
@@ -258,7 +280,7 @@ int add_pfs_instr_to_array(const char* n
   }
 
   /* Add to the array of default startup options */
-  if (insert_dynamic(&pfs_instr_init_array, &e))
+  if (insert_dynamic(&pfs_instr_config_array, &e))
   {
     my_free(e);
     return 1;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (chris.powers:3790) Christopher Powers30 Jan