From 048e9c40a661476d1b742f61d692f211acbd24d2 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 13 Feb 2014 10:44:10 +0400 Subject: MDEV-5492 - Reduce usage of LOCK_open: TABLE::in_use Move TABLE::in_use out of LOCK_open. This is done with assumtion that foreign threads accessing TABLE::in_use will only need consistent value _after_ marking table for flush and purging unused table instances. In this case TABLE::in_use will always point to a valid thread object. Previously FLUSH TABLES thread may wait for tables flushed subsequently by concurrent threads which breaks the above assumption, e.g.: open tables: t1 (version= 1) thr1 (FLUSH TABLES): refresh_version++ thr1 (FLUSH TABLES): purge table cache open tables: none thr2 (SELECT * FROM t1): open tables: t1 open tables: t1 (version= 2) thr2 (FLUSH TABLES): refresh_version++ thr2 (FLUSH TABLES): purge table cache thr1 (FLUSH TABLES): wait for old tables (including t1 with version 2) It is fixed so that FLUSH TABLES waits only for tables that were open heretofore. --- sql/sql_test.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sql/sql_test.cc') diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 922423bef26..8588d6564ca 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -94,12 +94,13 @@ static void print_cached_tables(void) TABLE_SHARE::All_share_tables_list::Iterator it(share->tdc.all_tables); while ((entry= it++)) { + THD *in_use= entry->in_use; printf("%-14.14s %-32s%6ld%8ld%6d %s\n", - entry->s->db.str, entry->s->table_name.str, entry->s->version, - entry->in_use ? entry->in_use->thread_id : 0, + entry->s->db.str, entry->s->table_name.str, entry->s->tdc.version, + in_use ? in_use->thread_id : 0, entry->db_stat ? 1 : 0, - entry->in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : - "Not in use"); + in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : + "Not in use"); } } mysql_mutex_unlock(&LOCK_open); -- cgit v1.2.1