mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-4702 - Reduce usage of LOCK_open
Following variables do not require LOCK_open protection anymore: - table_def_cache (renamed to tdc_hash) is protected by rw-lock LOCK_tdc_hash; - table_def_shutdown_in_progress doesn't need LOCK_open protection; - last_table_id use atomics; - TABLE_SHARE::ref_count (renamed to TABLE_SHARE::tdc.ref_count) is protected by TABLE_SHARE::tdc.LOCK_table_share; - TABLE_SHARE::next, ::prev (renamed to tdc.next and tdc.prev), oldest_unused_share, end_of_unused_share are protected by LOCK_unused_shares; - TABLE_SHARE::m_flush_tickets (renamed to tdc.m_flush_tickets) is protected by TABLE_SHARE::tdc.LOCK_table_share; - refresh_version (renamed to tdc_version) use atomics.
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
#include "sql_priv.h"
|
||||
#include "unireg.h"
|
||||
#include "sql_test.h"
|
||||
#include "sql_base.h" // table_def_cache, table_cache_count, unused_tables
|
||||
#include "sql_base.h" // unused_tables
|
||||
#include "sql_show.h" // calc_sum_of_all_status
|
||||
#include "sql_select.h"
|
||||
#include "keycaches.h"
|
||||
@ -78,21 +78,21 @@ print_where(COND *cond,const char *info, enum_query_type query_type)
|
||||
|
||||
static void print_cached_tables(void)
|
||||
{
|
||||
uint idx,count,unused;
|
||||
uint count= 0, unused= 0;
|
||||
TABLE_SHARE *share;
|
||||
TABLE *start_link, *lnk, *entry;
|
||||
TDC_iterator tdc_it;
|
||||
|
||||
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
|
||||
|
||||
/* purecov: begin tested */
|
||||
mysql_mutex_lock(&LOCK_open);
|
||||
puts("DB Table Version Thread Open Lock");
|
||||
|
||||
for (idx=unused=0 ; idx < table_def_cache.records ; idx++)
|
||||
tdc_it.init();
|
||||
mysql_mutex_lock(&LOCK_open);
|
||||
while ((share= tdc_it.next()))
|
||||
{
|
||||
share= (TABLE_SHARE*) my_hash_element(&table_def_cache, idx);
|
||||
|
||||
TABLE_SHARE::TABLE_list::Iterator it(share->used_tables);
|
||||
TABLE_SHARE::TABLE_list::Iterator it(share->tdc.used_tables);
|
||||
while ((entry= it++))
|
||||
{
|
||||
printf("%-14.14s %-32s%6ld%8ld%6d %s\n",
|
||||
@ -100,7 +100,7 @@ static void print_cached_tables(void)
|
||||
entry->in_use->thread_id, entry->db_stat ? 1 : 0,
|
||||
lock_descriptions[(int)entry->reginfo.lock_type]);
|
||||
}
|
||||
it.init(share->free_tables);
|
||||
it.init(share->tdc.free_tables);
|
||||
while ((entry= it++))
|
||||
{
|
||||
unused++;
|
||||
@ -109,7 +109,7 @@ static void print_cached_tables(void)
|
||||
0L, entry->db_stat ? 1 : 0, "Not in use");
|
||||
}
|
||||
}
|
||||
count=0;
|
||||
tdc_it.deinit();
|
||||
if ((start_link=lnk=unused_tables))
|
||||
{
|
||||
do
|
||||
@ -119,20 +119,18 @@ static void print_cached_tables(void)
|
||||
printf("unused_links isn't linked properly\n");
|
||||
return;
|
||||
}
|
||||
} while (count++ < cached_open_tables() && (lnk=lnk->next) != start_link);
|
||||
} while (count++ < tc_records() && (lnk=lnk->next) != start_link);
|
||||
if (lnk != start_link)
|
||||
{
|
||||
printf("Unused_links aren't connected\n");
|
||||
}
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_open);
|
||||
if (count != unused)
|
||||
printf("Unused_links (%d) doesn't match table_def_cache: %d\n", count,
|
||||
unused);
|
||||
printf("\nCurrent refresh version: %ld\n",refresh_version);
|
||||
if (my_hash_check(&table_def_cache))
|
||||
printf("Error: Table definition hash table is corrupted\n");
|
||||
printf("\nCurrent refresh version: %ld\n", tdc_refresh_version());
|
||||
fflush(stdout);
|
||||
mysql_mutex_unlock(&LOCK_open);
|
||||
/* purecov: end */
|
||||
return;
|
||||
}
|
||||
@ -485,7 +483,7 @@ static void display_table_locks(void)
|
||||
DYNAMIC_ARRAY saved_table_locks;
|
||||
|
||||
(void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO),
|
||||
cached_open_tables() + 20, 50,
|
||||
tc_records() + 20, 50,
|
||||
MYF(MY_THREAD_SPECIFIC));
|
||||
mysql_mutex_lock(&THR_LOCK_lock);
|
||||
for (list= thr_lock_thread_list; list; list= list_rest(list))
|
||||
@ -616,7 +614,7 @@ Open tables: %10lu\n\
|
||||
Open files: %10lu\n\
|
||||
Open streams: %10lu\n",
|
||||
tmp.opened_tables,
|
||||
(ulong) cached_open_tables(),
|
||||
(ulong) tc_records(),
|
||||
(ulong) my_file_opened,
|
||||
(ulong) my_stream_opened);
|
||||
|
||||
|
Reference in New Issue
Block a user