summaryrefslogtreecommitdiff
path: root/sql/table_cache.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-28836: Memory alignment cleanupMarko Mäkelä2022-06-211-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Table_cache_instance: Define the structure aligned at the CPU cache line, and remove a pad[] data member. Krunal Bauskar reported this to improve performance on ARMv8. aligned_malloc(): Wrapper for the Microsoft _aligned_malloc() and the ISO/IEC 9899:2011 <stdlib.h> aligned_alloc(). Note: The parameters are in the Microsoft order (size, alignment), opposite of aligned_alloc(alignment, size). Note: The standard defines that size must be an integer multiple of alignment. It is enforced by AddressSanitizer but not by GNU libc on Linux. aligned_free(): Wrapper for the Microsoft _aligned_free() and the standard free(). HAVE_ALIGNED_ALLOC: A new test. Unfortunately, support for aligned_alloc() may still be missing on some platforms. We will fall back to posix_memalign() for those cases. HAVE_MEMALIGN: Remove, along with any use of the nonstandard memalign(). PFS_ALIGNEMENT (sic): Removed; we will use CPU_LEVEL1_DCACHE_LINESIZE. PFS_ALIGNED: Defined using the C++11 keyword alignas. buf_pool_t::page_hash_table::create(), lock_sys_t::hash_table::create(): lock_sys_t::hash_table::resize(): Pad the allocation size to an integer multiple of the alignment. Reviewed by: Vladislav Vaintroub
* Fixed hang in concurrent DROP TABLE and BACKUP LOCK BLOCK_DDLMonty2021-05-191-1/+2
| | | | | | | | The problem was that tdc_remove_referenced_share() did not take into account that someone could push things into share->free_tables() even if there is a MDL_EXCLUSIVE lock on the table. This can happen if flush_tables() uses the table cache to flush a a non transactional table to disk.
* Yet less TDC hash lookupsSergey Vojtovich2020-04-031-11/+16
| | | | | | | Let auto repair table and truncate table routines flush TABLE_SHARE directly. Part of MDEV-17882 - Cleanup refresh version
* Split tdc_remove_table()Sergey Vojtovich2020-04-031-102/+104
| | | | | | | | | | | | | | TDC_RT_REMOVE_ALL -> tdc_remove_table(). Some occurrences replaced with TDC_element::flush() (whenver TABLE_SHARE is available). TDC_RT_REMOVE_NOT_OWN[_KEEP_SHARE] -> TDC_element::flush(). These modes assume that current thread owns TABLE_SHARE reference, which means we can avoid hash lookup and flush unused TABLE instances directly. TDC_RT_REMOVE_UNUSED -> TDC_element::flush_unused(). Only [ab]used by mysql_admin_table() currently. Should be removed eventually. Part of MDEV-17882 - Cleanup refresh version
* tc_remove_all_unused_tables() cleanupSergey Vojtovich2020-04-031-31/+11
| | | | | | | As tc_purge() never marks share flushed, let tdc_remove_table() do it directly. Part of MDEV-17882 - Cleanup refresh version
* Cleanup mysql_inplace_alter_table()Sergey Vojtovich2020-04-031-0/+17
| | | | | | | | Removed redundant tdc_remove_table(TDC_RT_REMOVE_ALL). Share was marked flushed by preceding wait_while_table_is_used() and eventually flushed by close_all_tables_for_name(). Part of MDEV-17882 - Cleanup refresh version
* Merge 10.4 into 10.5Marko Mäkelä2020-03-231-13/+21
|\
| * tc_active_instances: my_atomic to std::atomicSergey Vojtovich2020-03-211-13/+21
| |
* | cleanup: PSI key is *always* the first argumentSergei Golubchik2020-03-101-2/+3
| |
* | perfschema memory related instrumentation changesSergei Golubchik2020-03-101-3/+2
| |
* | Removed tc_purge() and purge_tables() argumentSergey Vojtovich2019-11-251-3/+3
| | | | | | | | | | | | | | | | It was mistakenly used by tdc_start_shutdown() to make sure TABLE_SHARE gets evicted from table definition cache when it becomes unused. However same effect is achieved by resetting tdc_size and tc_size. Part of MDEV-17882 - Cleanup refresh version
* | Removed kill_delayed_threads_for_table()Sergey Vojtovich2019-11-251-47/+1
| | | | | | | | | | | | | | | | | | | | After 7fb9d64 it is used only by ALTER/DROP SERVER, which most probably wasn't intentional as Federated never supported delayed inserts anyway. If delayed inserts will ever become an issue with ALTER/DROP SERVER, we should kill them by acquiring X-lock instead. Part of MDEV-17882 - Cleanup refresh version
* | Removed tdc_increment_refresh_version()Sergey Vojtovich2019-11-251-21/+4
|/ | | | | | | | | | | | | | | | | | | It is never called after 7fb9d64, which makes the whole refresh version infrastructure useless. Removed: - tdc_version_t - TDC_VERSION_MAX - tdc_version - TDC_element::version - tdc_increment_refresh_version() - tdc_refresh_version() - refresh_version argument of tdc_wait_for_old_version() - Flush_commands status variable - refresh version from COM_STATISTICS - refresh version from dbug printouts Part of MDEV-17882 - Cleanup refresh version
* Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\
| * Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\
| | * Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\
| | | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |
| | | * merge 10.0 -> 10.1 to resolve MDEV-17803 conflicts.Andrei Elkin2019-01-231-1/+4
| | | |
* | | | cleanup: replace a magic constant with a defineSergei Golubchik2019-05-181-1/+1
| | | |
* | | | tc_contention_warning_reported transition to std::atomicSergey Vojtovich2018-12-291-3/+3
| | | |
* | | | MDEV-17441 - InnoDB transition to C++11 atomicsSergey Vojtovich2018-12-281-1/+1
| | | | | | | | | | | | | | | | | | | | Added lf_hash_size() macro, so that callers don't need to use atomic operations.
* | | | Changed FLUSH TABLES to not change share versionMonty2018-12-091-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of MDEV-5336 Implement LOCK FOR BACKUP Originally both table metadata lock and global read lock protection were acquired before getting TABLE from table cache. This will be reordered in a future commit with MDL_BACKUP_XXX locks so that we first take table metadata lock, then get TABLE from table cache, then acquire analogue of global read lock. This patch both simplifies FLUSH TABLES code, makes FLUSH TABLES to lock less and also enables FLUSH TABLES code to be used with backup locks. The usage of FLUSH TABLES changes slightly: - FLUSH TABLES without any arguments will now only close not used tables and tables locked by the FLUSH TABLES connection. All not used table shares will be closed. Tables locked by the FLUSH TABLES connection will be reopened and re-locked after all others has stoped using the table (as before). If there was no locked tables, then FLUSH TABLES is instant and will not cause any waits. FLUSH TABLES will not wait for any in use table. - FLUSH TABLES with a table list, will ensure that the tables are closed before statement returns. The code is now only using MDL locks and not table share versions, which simplices the code greatly. One visible change is that the server will wait for the end of the transaction that are using the tables. Before FLUSH TABLES only waited for the statements to end. Signed-off-by: Monty <monty@mariadb.org>
* | | | Optimize flush tables with read lock (FTWRL) to not wait for select'sMonty2018-12-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of MDEV-5336 Implement LOCK FOR BACKUP The idea is that instead of waiting in close_cached_tables() for all tables to be closed, we instead call flush_tables() that does: - Flush not used objects in table cache to free memory - Collect all tables that are open - Call HA_EXTRA_FLUSH on the objects, to get them into "closed state" - Added HA_EXTRA_FLUSH support to archive and CSV - Added multi-user protection to HA_EXTRA_FLUSH in MyISAM and Aria The benefit compared to old code is: - FTWRL doesn't have to wait for long running read operations or open HANDLER's
* | | | Simple cleanups (no logic changes)Monty2018-12-091-4/+4
| | | |
* | | | Merge 10.3 into 10.4Marko Mäkelä2018-10-051-5/+14
|\ \ \ \ | |/ / /
| * | | Merge branch '10.2' into 10.3Sergei Golubchik2018-09-281-5/+14
| |\ \ \ | | |/ /
| | * | Merge branch '10.1' into 10.2Sergei Golubchik2018-09-241-0/+1
| | |\ \ | | | |/
| | | * Merge branch '10.0' into 10.1Sergei Golubchik2018-09-231-0/+1
| | | |\
| | | | * MDEV-14410 - Assertion `table->pos_in_locked_tables == __null ||Sergey Vojtovich2018-09-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | table->pos_in_locked_tables->table == table' failed in mark_used_tables_as_free_for_reuse Assertion failure can be triggered by some DDL executed under LOCK TABLES that holds lock for DDL target table multiple times (either explicitly or implcitly). When closing all table instances for given table (e.g. when preparing for table removal during CREATE OR REPLACE), only one instance was removed from m_locked_tables list. Later we attempt to re-insert one of the instances in mysql_create_table()/ add_back_last_deleted_lock(), which wasn't actually removed. This leads to m_locks_tables corruption, specifically loss of all following elements. Then UNLOCK TABLE won't reset some table instances properly (specifically pos_in_locked_tables), since they're not present in m_locked_tables. Eventually such table instance gets released to table cache and then re-used by subsequent statement, which triggers this assertion failure.
| | * | | Merge branch '10.1' into 10.2Oleksandr Byelkin2018-09-141-2/+0
| | |\ \ \ | | | |/ /
| | | * | Merge branch '11.0' into 10.1Oleksandr Byelkin2018-09-061-2/+0
| | | |\ \ | | | | |/
| | | | * MDEV-16757 Memory leak after adding manually min/max statistical dataSergey Vojtovich2018-09-051-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for blob column Moved delete_stat_values_for_table_share() call to proper place.
| | | | * MDEV-16757 Memory leak after adding manually min/max statistical dataIgor Babaev2018-07-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for blob column ANALYZE TABLE <table> does not collect statistical data on min/max values for BLOB columns of <table>. However these values can be added into mysql.column_stats manually by executing proper statements. Unfortunately this led to a memory leak because the memory allocated for these values was never freed. This patch provides the server with a function to free memory allocated for min/max statistical values of BLOB types.
| | * | | MDEV-16773 - Assertion failed in tdc_remove_tableSergey Vojtovich2018-09-101-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This assertion fails in thread that removes all table instances for particular table from table cache (e.g. "DROP TABLE") while another thread evicts table instance of the same table from table cache concurrently. After "MDEV-10296 - Multi-instance table cache" there is a gap in eviction code of tc_add_table() between removing table from free_tables and all_tables not protected by any mutexes. This is now valid table cache state, however assertion wasn't amended along with original patch. Moved assertion down, after waiting for such table instances to get closed.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2018-08-161-0/+2
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2018-08-031-0/+2
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2018-08-021-0/+2
| | |\ \ \ | | | |/ /
| | | * | MDEV-16757 Memory leak after adding manually min/max statistical dataIgor Babaev2018-07-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for blob column ANALYZE TABLE <table> does not collect statistical data on min/max values for BLOB columns of <table>. However these values can be added into mysql.column_stats manually by executing proper statements. Unfortunately this led to a memory leak because the memory allocated for these values was never freed. This patch provides the server with a function to free memory allocated for min/max statistical values of BLOB types. Temporarily changed the test case until MDEV-16711 is fixed as without this fix the test case for MDEV-16757 did not fail only for 10.0.
* | | | | MDEV-16421 Make system tables crash safeMichael Widenius2018-08-141-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make all system tables in mysql directory of type engine=Aria Privilege tables are using transactional=1 Statistical tables are using transactional=0, to allow them to be quickly updated with low overhead. Help tables are also using transactional=0 as these are only updated at init time. Other changes: - Aria store engine is now a required engine - Update comment for Aria tables to reflect their new usage - Fixed that _ma_reset_trn_for_table() removes unlocked table from transaction table list. This was needed to allow one to lock and unlock system tables separately from other tables, for example when reading a procedure from mysql.proc - Don't give a warning when using transactional=1 for engines that is using transactions. This is both logical and also to avoid warnings/errors when doing an alter of a privilege table to InnoDB. - Don't abort on warnings from ALTER TABLE for changes that would be accepted by CREATE TABLE. - New created Aria transactional tables are marked as not movable (as they include create_rename_lsn). - bootstrap.test was changed to kill orignal server, as one can't anymore have two servers started at same time on same data directory and data files. - Disable maria.small_blocksize as one can't anymore change aria block size after system tables are created. - Speed up creation of help tables by using lock tables. - wsrep_sst_resync now also copies Aria redo logs.
* | | | Add checking of correct likely/unlikelyMichael Widenius2018-05-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To use: - Compile with -DUSE_MY_LIKELY - Change (with replace) all likely/unlikely to my_likely/my_/unlikely replace likely my_likely unlikely my_unlikely -- *c *h - Start mysqld with -T - run some test - When mysqld has shut down cleanely, report will be on stderr
* | | | Add likely/unlikely to speed up executionMonty2018-05-071-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed()
* | | | MDEV-15149 Assert upon concurrent creating / querying sequencesMonty2018-03-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Problem was that sequence_insert closed and reopened the like table without proper locking. Fixed by ensuring that the like table is not reopened in sequence_insert
* | | | MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from ↵Vladislav Vaintroub2018-02-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'size_t' to 'type', possible loss of data) Handle string length as size_t, consistently (almost always:)) Change function prototypes to accept size_t, where in the past ulong or uint were used. change local/member variables to size_t when appropriate. This fix excludes rocksdb, spider,spider, sphinx and connect for now.
* | | | Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3Alexander Barkov2018-02-041-1/+2
|\ \ \ \
| * | | | Added name to MEM_ROOT for esier debuggingMonty2018-02-021-1/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will make it easier to how memory allocation is done when debugging with either DBUG or gdb. Will especially help when debugging stored procedures Main change is a name argument as second argument to init_alloc_root() init_sql_alloc() Other things: - Added DBUG_ENTER/EXIT to some Virtual_tmp_table functions
* | | | Changed database, tablename and alias to be LEX_CSTRINGMonty2018-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was done in, among other things: - thd->db and thd->db_length - TABLE_LIST tablename, db, alias and schema_name - Audit plugin database name - lex->db - All db and table names in Alter_table_ctx - st_select_lex db Other things: - Changed a lot of functions to take const LEX_CSTRING* as argument for db, table_name and alias. See init_one_table() as an example. - Changed some function arguments from LEX_CSTRING to const LEX_CSTRING - Changed some lists from LEX_STRING to LEX_CSTRING - threads_mysql.result changed because process list_db wasn't always correctly updated - New append_identifier() function that takes LEX_CSTRING* as arguments - Added new element tmp_buff to Alter_table_ctx to separate temp name handling from temporary space - Ensure we store the length after my_casedn_str() of table/db names - Removed not used version of rename_table_in_stat_tables() - Changed Natural_join_column::table_name and db_name() to never return NULL (used for print) - thd->get_db() now returns db as a printable string (thd->db.str or "")
* | | | MDEV-11153 - Introduce status variables for table cache monitoring and tuningSergey Vojtovich2017-10-311-9/+26
| | | | | | | | | | | | | | | | | | | | Status variables added: Table_open_cache_hits, Table_open_cache_misses, Table_open_cache_overflows, Table_open_cache_active_instances.
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-10-041-12/+11
|\ \ \ \ | |/ / /
| * | | In table cache code, fix casts from longlong to long forVladislav Vaintroub2017-09-291-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'version' variables. The warnings occur on Windows build, yet they are also are valid on 32bit Unix. Fix is to consistently use 64bit integer on all platforms.
| * | | MDEV-13384 - misc Windows warnings fixedVladislav Vaintroub2017-09-281-2/+2
| | | |