summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-08-08 14:53:52 +0300
committerMichael Widenius <monty@askmonty.org>2011-08-08 14:53:52 +0300
commitcfd2725d6131ec94bb2bf4de7c607040e1611e06 (patch)
tree9064b9031409b32ae338bcb3dceb4fafa9e6e757
parent51c7723eb2faf7bb9de8d0a2a3b364b07f82b0fd (diff)
downloadmariadb-git-cfd2725d6131ec94bb2bf4de7c607040e1611e06.tar.gz
Optimize mutex usage.
storage/maria/ma_blockrec.c: Unlock bitmaps earlier (no reason to have them unlocked over _ma_write_clr()) storage/maria/ma_extra.c: Don't lock THR_LOCK_maria for HA_EXTRA_PREPARE_FOR_RENAME (upper level ensures that we are not opening the same table during this call) We don't need to have share->intern_lock locked over _ma_flush_table_files() storage/maria/ma_open.c: Update comment
-rw-r--r--storage/maria/ma_blockrec.c2
-rw-r--r--storage/maria/ma_extra.c6
-rw-r--r--storage/maria/ma_open.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c
index 3a5bbd6c6f2..36cd63667e7 100644
--- a/storage/maria/ma_blockrec.c
+++ b/storage/maria/ma_blockrec.c
@@ -3643,6 +3643,7 @@ my_bool _ma_write_abort_block_record(MARIA_HA *info)
}
}
}
+ _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(MARIA_HA *info)
&lsn, (void*) 0))
res= 1;
}
- _ma_bitmap_unlock(share);
_ma_unpin_all_pages_and_finalize_row(info, lsn);
DBUG_RETURN(res);
}
diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c
index d986525814e..7ecc36c602c 100644
--- a/storage/maria/ma_extra.c
+++ b/storage/maria/ma_extra.c
@@ -319,7 +319,6 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
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_extra_function function,
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_extra_function function,
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:
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index 92f50b0756c..f9ec70499f1 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -922,7 +922,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
{
/*
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);