InnoDB Loading data dictionary && flush tables

Source: Internet
Author: User
Tags table definition

Tested two case, which belongs to the legacy of the previous blog:

    1. InnoDB How to load a data dictionary
    2. What did flush tables do?

Let's take a look at the InnoDB load data dictionary:

First Use: SELECT * from TT;

1. Create a Handler object

function Call Stack:
Open_binary_frm
Get_new_handler
Innobase_create_handler
Ha_innobase::ha_innobase

Based on the single instance Handlerton + table_share two parameters, the handler object is created, and the assignment table->file. The server layer operates on the InnoDB, which is done through this interface.

2. Open Innobase_share

Innobase_share is the INNODB layer to a table definition, the global shared structure, protected by Innobase_share_mutex.

The Innobase_open_tables hash table holds all the innobase_share.

This completes the initialization of a innobase_share structure.


3. Load the data dictionary:

Initializing the dict_table_t in Innodb_share

Steps:
Mutex_enter (& (Dict_sys->mutex));
dict_sys_t: The whole system data dictionary, the global Dict_sys_t*dict_sys;
Includes:hash_table_t*table_hash;/*!< hash table of the tables, based
Includes: ut_list_base_node_t (dict_table_t) table_lru;/*!< LRU LIST of tables */

Dict_table_get
Dict_table_get_low
Presence: Dict_table_check_if_in_cache_low: Remove from the hash table and update the LRU list.
Not present: dict_load_table

1. Load table Definition
2. Load Columns
3. Load Index
4. Load FOREIGN key

Note: The array dictionary uses two structure storage, one hash is convenient to query, and the other is the LRU linked list, which is used for buffer substitution.

Flush tables;


Reload_acl_and_cache:
1. Empty Query_cache: Use Structure_guard_mutex lock.
2. Close_cached_tables: Off is not used. Use the Lock_open lock for protection.
3. Increment: refresh_version

Free_cache_entry:free off the table in Table_cache
Inter_close_table: Empty Io_cache
CLOSEFRM:

    1. Close Handler
    2. Free Innobase_share
    3. Release Table_share: Removed from Table_def_cache.

Record Binlog:

Flush Talbes Records the binlog of statement.

Note: If flush tables with read lock is used: The global read lock will be used with Meta lock.

Conclusion:
For a table, flush_tables altogether closed table, Table_share, Handler, Innobase_share. Only the dict_table_t data dictionary is retained.
Flush tables does not close in use and when table is used again, it finds that version has changed, closes it, and turns it back on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.