List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:November 23 2009 4:59pm
Subject:bzr push into mysql-5.6-next-mr branch (mikael:2926 to 2927) WL#5138
View as plain text  
 2927 Mikael Ronstrom	2009-11-23
      WL#5138, fixed review comments

    modified:
      sql/event_scheduler.cc
      sql/log_event.cc
      sql/mysql_priv.h
      sql/mysqld.cc
      sql/sp_head.cc
      sql/sql_parse.cc
 2926 Mikael Ronstrom	2009-11-20
      WL#5138, reverted some review fixes

    modified:
      sql/mysql_priv.h
      sql/mysqld.cc
=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2009-11-20 15:43:21 +0000
+++ b/sql/event_scheduler.cc	2009-11-23 16:57:21 +0000
@@ -133,10 +133,8 @@ post_init_event_thread(THD *thd)
   pthread_mutex_lock(&LOCK_thread_count);
   threads.append(thd);
   thread_count++;
-  pthread_mutex_unlock(&LOCK_thread_count);
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
   inc_thread_running();
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
+  pthread_mutex_unlock(&LOCK_thread_count);
   return FALSE;
 }
 
@@ -158,9 +156,7 @@ deinit_event_thread(THD *thd)
   DBUG_PRINT("exit", ("Event thread finishing"));
   pthread_mutex_lock(&LOCK_thread_count);
   thread_count--;
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
   dec_thread_running();
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
   delete thd;
   pthread_cond_broadcast(&COND_thread_count);
   pthread_mutex_unlock(&LOCK_thread_count);
@@ -421,9 +417,7 @@ Event_scheduler::start()
     net_end(&new_thd->net);
     pthread_mutex_lock(&LOCK_thread_count);
     thread_count--;
-    my_atomic_rwlock_wrlock(&global_query_id_lock);
     dec_thread_running();
-    my_atomic_rwlock_wrunlock(&global_query_id_lock);
     delete new_thd;
     pthread_cond_broadcast(&COND_thread_count);
     pthread_mutex_unlock(&LOCK_thread_count);
@@ -556,9 +550,7 @@ error:
     net_end(&new_thd->net);
     pthread_mutex_lock(&LOCK_thread_count);
     thread_count--;
-    my_atomic_rwlock_wrlock(&global_query_id_lock);
     dec_thread_running();
-    my_atomic_rwlock_wrunlock(&global_query_id_lock);
     delete new_thd;
     pthread_cond_broadcast(&COND_thread_count);
     pthread_mutex_unlock(&LOCK_thread_count);

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-11-20 15:23:32 +0000
+++ b/sql/log_event.cc	2009-11-23 16:57:21 +0000
@@ -3056,9 +3056,7 @@ int Query_log_event::do_apply_event(Rela
   {
     thd->set_time((time_t)when);
     thd->set_query((char*)query_arg, q_len_arg);
-    my_atomic_rwlock_wrlock(&global_query_id_lock);
     thd->query_id = next_query_id();
-    my_atomic_rwlock_wrunlock(&global_query_id_lock);
     thd->variables.pseudo_thread_id= thread_id;		// for temp tables
     DBUG_PRINT("query",("%s", thd->query()));
 
@@ -4581,9 +4579,7 @@ int Load_log_event::do_apply_event(NET* 
   if (rpl_filter->db_ok(thd->db))
   {
     thd->set_time((time_t)when);
-    my_atomic_rwlock_wrlock(&global_query_id_lock);
     thd->query_id = next_query_id();
-    my_atomic_rwlock_wrunlock(&global_query_id_lock);
     thd->warning_info->opt_clear_warning_info(thd->query_id);
 
     TABLE_LIST tables;
@@ -8072,9 +8068,7 @@ int Table_map_log_event::do_apply_event(
   DBUG_ASSERT(rli->sql_thd == thd);
 
   /* Step the query id to mark what columns that are actually used. */
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
   thd->query_id= next_query_id();
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
 
   if (!(memory= my_multi_malloc(MYF(MY_WME),
                                 &table_list, (uint) sizeof(RPL_TABLE_LIST),

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2009-11-20 17:42:15 +0000
+++ b/sql/mysql_priv.h	2009-11-23 16:57:21 +0000
@@ -90,19 +90,24 @@ typedef int64 query_id_t;
 extern query_id_t global_query_id;
 extern int32 thread_running;
 extern my_atomic_rwlock_t global_query_id_lock;
+extern my_atomic_rwlock_t thread_running_lock;
 
 /* increment query_id and return it.  */
 inline query_id_t next_query_id()
 {
   query_id_t id;
+  my_atomic_rwlock_wrlock(&global_query_id_lock);
   id= my_atomic_add64(&global_query_id, 1);
+  my_atomic_rwlock_wrunlock(&global_query_id_lock);
   return (id+1);
 }
 
 inline query_id_t get_query_id()
 {
   query_id_t id;
+  my_atomic_rwlock_wrlock(&global_query_id_lock);
   id= my_atomic_load64(&global_query_id);
+  my_atomic_rwlock_wrunlock(&global_query_id_lock);
   return id;
 }
 
@@ -110,7 +115,9 @@ inline int32
 inc_thread_running()
 {
   int32 num_thread_running;
+  my_atomic_rwlock_wrlock(&thread_running_lock);
   num_thread_running= my_atomic_add32(&thread_running, 1);
+  my_atomic_rwlock_wrunlock(&thread_running_lock);
   return (num_thread_running+1);
 }
 
@@ -118,7 +125,9 @@ inline int32
 dec_thread_running()
 {
   int32 num_thread_running;
+  my_atomic_rwlock_wrlock(&thread_running_lock);
   num_thread_running= my_atomic_add32(&thread_running, -1);
+  my_atomic_rwlock_wrunlock(&thread_running_lock);
   return (num_thread_running-1);
 }
 
@@ -126,7 +135,9 @@ inline int32
 get_thread_running()
 {
   int32 num_thread_running;
+  my_atomic_rwlock_wrlock(&thread_running_lock);
   num_thread_running= my_atomic_load32(&thread_running);
+  my_atomic_rwlock_wrunlock(&thread_running_lock);
   return num_thread_running;
 }
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-11-20 17:42:15 +0000
+++ b/sql/mysqld.cc	2009-11-23 16:57:21 +0000
@@ -549,6 +549,7 @@ ulong query_cache_size=0;
 ulong refresh_version;  /* Increments on each reload */
 query_id_t global_query_id;
 my_atomic_rwlock_t global_query_id_lock;
+my_atomic_rwlock_t thread_running_lock;
 ulong aborted_threads, aborted_connects;
 ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size;
 ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
@@ -1383,6 +1384,7 @@ void clean_up(bool print_message)
   /* Tell main we are ready */
   logger.cleanup_end();
   my_atomic_rwlock_destroy(&global_query_id_lock);
+  my_atomic_rwlock_destroy(&thread_running_lock);
   (void) pthread_mutex_lock(&LOCK_thread_count);
   DBUG_PRINT("quit", ("got thread count lock"));
   ready_to_exit=1;
@@ -7799,6 +7801,7 @@ static int mysql_init_variables(void)
   refresh_version= 1L;	/* Increments on each reload */
   global_query_id= thread_id= 1L;
   my_atomic_rwlock_init(&global_query_id_lock);
+  my_atomic_rwlock_init(&thread_running_lock);
   strmov(server_version, MYSQL_SERVER_VERSION);
   myisam_recover_options_str= sql_mode_str= "OFF";
   myisam_stats_method_str= "nulls_unequal";

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2009-11-20 15:23:32 +0000
+++ b/sql/sp_head.cc	2009-11-23 16:57:21 +0000
@@ -2736,9 +2736,7 @@ sp_lex_keeper::reset_lex_and_exec_core(T
   */
   thd->lex= m_lex;
 
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
   thd->query_id= next_query_id();
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
 
   if (thd->prelocked_mode == NON_PRELOCKED)
   {

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2009-11-20 15:23:32 +0000
+++ b/sql/sql_parse.cc	2009-11-23 16:57:21 +0000
@@ -495,9 +495,7 @@ static void handle_bootstrap_impl(THD *t
       We don't need to obtain LOCK_thread_count here because in bootstrap
       mode we have only one thread.
     */
-    my_atomic_rwlock_wrlock(&global_query_id_lock);
     thd->query_id=next_query_id();
-    my_atomic_rwlock_wrunlock(&global_query_id_lock);
     thd->set_time();
     mysql_parse(thd, thd->query(), length, & found_semicolon);
     close_thread_tables(thd);			// Free tables
@@ -991,7 +989,6 @@ bool dispatch_command(enum enum_server_c
   thd->enable_slow_log= TRUE;
   thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
   thd->set_time();
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
   {
     query_id_t query_id;
     switch( command ) {
@@ -1014,7 +1011,6 @@ bool dispatch_command(enum enum_server_c
     thd->query_id= query_id;
   }
   inc_thread_running();
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
 
   /**
     Clear the set of flags that are expected to be cleared at the
@@ -1284,9 +1280,7 @@ bool dispatch_command(enum enum_server_c
         Count each statement from the client.
       */
       statistic_increment(thd->status_var.questions, &LOCK_status);
-      my_atomic_rwlock_wrlock(&global_query_id_lock);
       thd->query_id= next_query_id();
-      my_atomic_rwlock_wrunlock(&global_query_id_lock);
       thd->set_time(); /* Reset the query start time. */
       /* TODO: set thd->lex->sql_command to SQLCOM_END here */
       mysql_parse(thd, beginning_of_next_stmt, length, &end_of_stmt);
@@ -1604,9 +1598,7 @@ bool dispatch_command(enum enum_server_c
   thd_proc_info(thd, "cleaning up");
   thd->set_query(NULL, 0);
   thd->command=COM_SLEEP;
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
   dec_thread_running();
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
   thd_proc_info(thd, 0);
   thd->packet.shrink(thd->variables.net_buffer_length);	// Reclaim some memory
   free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));


Attachment: [text/bzr-bundle] bzr/mikael@mysql.com-20091123165721-lsfqk6h580rmiblb.bundle
Thread
bzr push into mysql-5.6-next-mr branch (mikael:2926 to 2927) WL#5138Mikael Ronstrom23 Nov