1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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.
This commit is contained in:
Sergey Vojtovich
2014-02-13 10:44:10 +04:00
parent a25d87e50f
commit 048e9c40a6
8 changed files with 83 additions and 120 deletions

View File

@@ -481,8 +481,6 @@ TABLE_CATEGORY get_table_category(const LEX_STRING *db,
struct TABLE_share;
struct All_share_tables;
extern ulong tdc_refresh_version(void);
typedef struct st_table_field_type
{
LEX_STRING name;
@@ -623,6 +621,8 @@ struct TABLE_SHARE
*/
All_share_tables_list all_tables;
TABLE_list free_tables;
ulong version;
bool flushed;
} tdc;
LEX_CUSTRING tabledef_version;
@@ -668,7 +668,6 @@ struct TABLE_SHARE
key_map keys_for_keyread;
ha_rows min_rows, max_rows; /* create information */
ulong avg_row_length; /* create information */
ulong version;
ulong mysql_version; /* 0 if .frm is created before 5.0 */
ulong reclength; /* Recordlength */
/* Stored record length. No generated-only virtual fields are included */
@@ -847,12 +846,6 @@ struct TABLE_SHARE
return table_map_id;
}
/** Is this table share being expelled from the table definition cache? */
inline bool has_old_version() const
{
return version != tdc_refresh_version();
}
/**
Convert unrelated members of TABLE_SHARE to one enum
representing its type.