mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
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
This commit is contained in:
parent
51c7723eb2
commit
cfd2725d61
3 changed files with 5 additions and 5 deletions
|
@ -3643,6 +3643,7 @@ my_bool _ma_write_abort_block_record(MARIA_HA *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ma_bitmap_unlock(share);
|
||||||
if (share->now_transactional)
|
if (share->now_transactional)
|
||||||
{
|
{
|
||||||
if (_ma_write_clr(info, info->cur_row.orig_undo_lsn,
|
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))
|
&lsn, (void*) 0))
|
||||||
res= 1;
|
res= 1;
|
||||||
}
|
}
|
||||||
_ma_bitmap_unlock(share);
|
|
||||||
_ma_unpin_all_pages_and_finalize_row(info, lsn);
|
_ma_unpin_all_pages_and_finalize_row(info, lsn);
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 do_flush= test(function != HA_EXTRA_PREPARE_FOR_DROP);
|
||||||
my_bool save_global_changed;
|
my_bool save_global_changed;
|
||||||
enum flush_type type;
|
enum flush_type type;
|
||||||
pthread_mutex_lock(&THR_LOCK_maria);
|
|
||||||
/*
|
/*
|
||||||
This share, to have last_version=0, needs to save all its data/index
|
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
|
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;
|
type= do_flush ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED;
|
||||||
save_global_changed= share->global_changed;
|
save_global_changed= share->global_changed;
|
||||||
share->global_changed= 1; /* Don't increment open count */
|
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,
|
if (_ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
|
||||||
type, type))
|
type, type))
|
||||||
{
|
{
|
||||||
error=my_errno;
|
error=my_errno;
|
||||||
share->changed= 1;
|
share->changed= 1;
|
||||||
}
|
}
|
||||||
|
pthread_mutex_lock(&share->intern_lock);
|
||||||
share->global_changed= save_global_changed;
|
share->global_changed= save_global_changed;
|
||||||
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
|
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;
|
error= my_errno;
|
||||||
share->bitmap.changed_not_flushed= 0;
|
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 */
|
share->last_version= 0L; /* Impossible version */
|
||||||
pthread_mutex_unlock(&share->intern_lock);
|
pthread_mutex_unlock(&share->intern_lock);
|
||||||
pthread_mutex_unlock(&THR_LOCK_maria);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE:
|
case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE:
|
||||||
|
|
|
@ -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
|
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->intern_lock);
|
||||||
pthread_mutex_lock(&share->bitmap.bitmap_lock);
|
pthread_mutex_lock(&share->bitmap.bitmap_lock);
|
||||||
|
|
Loading…
Reference in a new issue