[Commits] Rev 3008: Optimize mutex usage. in lp:maria/5.2

Michael Widenius monty at askmonty.org
Mon Aug 8 14:53:53 EEST 2011


At lp:maria/5.2

------------------------------------------------------------
revno: 3008
revision-id: monty at askmonty.org-20110808115352-fp8teog8db3dm6ej
parent: knielsen at knielsen-hq.org-20110801085624-tltcaz0w4sits9gh
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.2
timestamp: Mon 2011-08-08 14:53:52 +0300
message:
  Optimize mutex usage.
-------------- next part --------------
=== modified file 'storage/maria/ma_blockrec.c'
--- a/storage/maria/ma_blockrec.c	2011-07-26 04:52:15 +0000
+++ b/storage/maria/ma_blockrec.c	2011-08-08 11:53:52 +0000
@@ -3643,6 +3643,7 @@ my_bool _ma_write_abort_block_record(MAR
       }
     }
   }
+  _ma_bitmap_unlock(share);
   if (share->now_transactional)
   {
     if (_ma_write_clr(info, info->cur_row.orig_undo_lsn,
@@ -3652,7 +3653,6 @@ my_bool _ma_write_abort_block_record(MAR
                       &lsn, (void*) 0))
       res= 1;
   }
-  _ma_bitmap_unlock(share);
   _ma_unpin_all_pages_and_finalize_row(info, lsn);
   DBUG_RETURN(res);
 }

=== modified file 'storage/maria/ma_extra.c'
--- a/storage/maria/ma_extra.c	2011-02-10 18:33:51 +0000
+++ b/storage/maria/ma_extra.c	2011-08-08 11:53:52 +0000
@@ -319,7 +319,6 @@ int maria_extra(MARIA_HA *info, enum ha_
     my_bool do_flush= test(function != HA_EXTRA_PREPARE_FOR_DROP);
     my_bool save_global_changed;
     enum flush_type type;
-    pthread_mutex_lock(&THR_LOCK_maria);
     /*
       This share, to have last_version=0, needs to save all its data/index
       blocks to disk if this is not for a DROP TABLE. Otherwise they would be
@@ -353,12 +352,14 @@ int maria_extra(MARIA_HA *info, enum ha_
     type= do_flush ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED;
     save_global_changed= share->global_changed;
     share->global_changed= 1;                 /* Don't increment open count */
+    pthread_mutex_unlock(&share->intern_lock);
     if (_ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
                               type, type))
     {
       error=my_errno;
       share->changed= 1;
     }
+    pthread_mutex_lock(&share->intern_lock);
     share->global_changed= save_global_changed;
     if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
     {
@@ -395,10 +396,9 @@ int maria_extra(MARIA_HA *info, enum ha_
         error= my_errno;
       share->bitmap.changed_not_flushed= 0;
     }
-    /* For protection against Checkpoint, we set under intern_lock: */
+    /* last_version must be protected by intern_lock; See collect_tables() */
     share->last_version= 0L;                    /* Impossible version */
     pthread_mutex_unlock(&share->intern_lock);
-    pthread_mutex_unlock(&THR_LOCK_maria);
     break;
   }
   case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE:

=== modified file 'storage/maria/ma_open.c'
--- a/storage/maria/ma_open.c	2011-07-26 04:52:15 +0000
+++ b/storage/maria/ma_open.c	2011-08-08 11:53:52 +0000
@@ -922,7 +922,7 @@ MARIA_HA *maria_open(const char *name, i
     {
       /*
         We must have internal_lock before bitmap_lock because we call
-        _ma_flush_tables_files() with internal_lock locked.
+        _ma_flush_table_files() with internal_lock locked.
       */
       pthread_mutex_lock(&share->intern_lock);
       pthread_mutex_lock(&share->bitmap.bitmap_lock);



More information about the commits mailing list