List:Commits« Previous MessageNext Message »
From:igor Date:December 23 2007 1:40am
Subject:bk commit into 5.2 tree (igor:1.2597)
View as plain text  
Below is the list of changes that have just been committed into a local
5.2 repository of igor. When igor 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-12-22 17:40:40-08:00, igor@stripped +3 -0
  WL #2771: BKA prototype.
      Experimental code, will not be pushed:
       Make DS-MRR implementation serialize disk sweep passes using a mutex.

  sql/handler.cc@stripped, 2007-12-22 17:40:37-08:00, igor@stripped +36 -0
    WL #2771: BKA prototype.
        Experimental code, will not be pushed:
         Make DS-MRR implementation serialize disk sweep passes using a mutex.

  sql/handler.h@stripped, 2007-12-22 17:40:37-08:00, igor@stripped +9 -0
    WL #2771: BKA prototype.
        Experimental code, will not be pushed:
         Make DS-MRR implementation serialize disk sweep passes using a mutex.

  sql/mysqld.cc@stripped, 2007-12-22 17:40:37-08:00, igor@stripped +2 -0
    WL #2771: BKA prototype.
        Experimental code, will not be pushed:
         Make DS-MRR implementation serialize disk sweep passes using a mutex.

diff -Nrup a/sql/handler.cc b/sql/handler.cc
--- a/sql/handler.cc	2007-10-22 05:30:00 -07:00
+++ b/sql/handler.cc	2007-12-22 17:40:37 -08:00
@@ -3415,6 +3415,18 @@ start:
  * DS-MRR implementation 
  ***************************************************************************/
 
+pthread_mutex_t dsmrr_mutex;
+pthread_mutexattr_t dsmrr_mutex_attr;
+
+void dsmrr_static_init()
+{
+  if (pthread_mutexattr_init(&dsmrr_mutex_attr))
+    fprintf(stderr, "dsmrr_mutex pthread_mutexattr_init failed\n");
+  pthread_mutexattr_settype(&dsmrr_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
+  if (pthread_mutex_init(&dsmrr_mutex, &dsmrr_mutex_attr))
+    fprintf(stderr, "dsmrr_mutex pthread_mutex_init failed\n");
+}
+ 
 /*
   DS-MRR: Initialize and start MRR scan
 
@@ -3517,6 +3529,15 @@ int DsMrr_impl::dsmrr_init(handler *h, K
   if (h2->rnd_init(FALSE))
     goto error;
 
+  /*
+    The 'normal' state of initialized DS-MRR scan is disk-sweep, which is
+    interrupted by periods when we walk the index.
+   
+    So we lock the mutex now and will unlock it when doing disk sweeps.
+  */
+  pthread_mutex_lock(&dsmrr_mutex);
+  need_unlock= TRUE;
+
   DBUG_RETURN(0);
 error:
   h2->ha_external_lock(thd, F_UNLCK);
@@ -3530,6 +3551,11 @@ error:
 void DsMrr_impl::dsmrr_close()
 {
   DBUG_ENTER("DsMrr_impl::dsmrr_close");
+  if (need_unlock)
+  {
+    pthread_mutex_unlock(&dsmrr_mutex);
+    need_unlock= FALSE;
+  }
   if (h2)
   {
     h2->ha_external_lock(current_thd, F_UNLCK);
@@ -3623,6 +3649,8 @@ int DsMrr_impl::dsmrr_next(handler *h, c
     
   do
   {
+    pthread_mutex_unlock(&dsmrr_mutex);
+    need_unlock= FALSE;
     if (rowids_buf_cur == rowids_buf_last)
     {
       h->table->column_bitmaps_set_no_signal(save_read_set, save_write_set);
@@ -3636,7 +3664,10 @@ int DsMrr_impl::dsmrr_next(handler *h, c
       h->table->column_bitmaps_set_no_signal(&row_access_bitmap,
                                              &row_access_bitmap);
       if (res)
+      {
+        // Keep unlocked.
         goto end;
+      }
     }
     
     /* Return EOF if there are no rowids in the buffer after re-fill attempt */
@@ -3645,6 +3676,11 @@ int DsMrr_impl::dsmrr_next(handler *h, c
       res= HA_ERR_END_OF_FILE;
       goto end;
     }
+   
+    /* Switching to Sweep read read. Lock the mutex back */
+    need_unlock= TRUE;
+    pthread_mutex_lock(&dsmrr_mutex);
+     
     cur_rowid= rowids_buf_cur;
     rowids_buf_cur += h->ref_length + sizeof(void*) * test(is_mrr_assoc);
      
diff -Nrup a/sql/handler.h b/sql/handler.h
--- a/sql/handler.h	2007-10-20 09:04:55 -07:00
+++ b/sql/handler.h	2007-12-22 17:40:37 -08:00
@@ -2042,6 +2042,14 @@ private:
   }
 };
 
+/*
+  A mutex used to disallow two disk sweeps to run at the same time.
+
+*/
+extern pthread_mutex_t dsmrr_mutex;
+extern pthread_mutexattr_t dsmrr_mutex_attr;
+
+void dsmrr_static_init();
 
 /*
   A Disk-Sweep MRR interface implementation
@@ -2092,6 +2100,7 @@ public:
   range_check_toggle_func_t range_check_toggle_func;
 
 
+  bool need_unlock;
   int dsmrr_init(handler *h, KEY *key, RANGE_SEQ_IF *seq_funcs, 
                  void *seq_init_param, uint n_ranges, uint mode, 
                  HANDLER_BUFFER *buf);
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2007-10-22 05:30:00 -07:00
+++ b/sql/mysqld.cc	2007-12-22 17:40:37 -08:00
@@ -3713,6 +3713,7 @@ void decrement_handler_count()
 #define decrement_handler_count()
 #endif /* defined(__NT__) || defined(HAVE_SMEM) */
 
+void dsmrr_static_init();
 
 #ifndef EMBEDDED_LIBRARY
 #ifdef __WIN__
@@ -3736,6 +3737,7 @@ int main(int argc, char **argv)
     MY_INIT, as it initializes mutexes. Log tables are inited later.
   */
   logger.init_base();
+  dsmrr_static_init();
 
 #ifdef _CUSTOMSTARTUPCONFIG_
   if (_cust_check_startup())
Thread
bk commit into 5.2 tree (igor:1.2597)igor23 Dec