summaryrefslogtreecommitdiff
path: root/sql/threadpool_common.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.3' into 10.4Oleksandr Byelkin2019-12-091-1/+1
|\
| * Lintian complains on spelling errorFaustin Lammler2019-12-021-1/+1
| | | | | | | | | | The lintian check complains on spelling error: https://salsa.debian.org/mariadb-team/mariadb-10.3/-/jobs/95739
* | MDEV-19826 10.4 seems to crash with "pool-of-threads" (#1370)Teemu Ollakka2019-08-301-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MariaDB 10.4 was crashing when thread-handling was set to pool-of-threads and wsrep was enabled. There were two apparent reasons for the crash: - Connection handling in threadpool_common.cc was missing calls to control wsrep client state. - Thread specific storage which contains thread variables (THR_KEY_mysys) was not handled appropriately by wsrep patch when pool-of-threads was configured. This patch addresses the above issues in the following way: - Wsrep client state open/close was moved in thd_prepare_connection() and end_connection() to have common handling for one-thread-per-connection and pool-of-threads. - Thread local storage handling in wsrep patch was reworked by introducing set of wsrep_xxx_threadvars() calls which replace calls to THD store_globals()/reset_globals() and deal with thread handling specifics internally. Wsrep-lib was updated to version which relaxes internal concurrency related sanity checks. Rollback code from wsrep_rollback_process() was extracted to separate calls for better readability. Post rollback thread was removed as it was completely unused.
* | Merge 10.3 into 10.4Marko Mäkelä2019-07-021-1/+2
|\ \ | |/
| * Merge 10.2 into 10.3Marko Mäkelä2019-07-021-1/+2
| |\
| | * Merge 10.1 into 10.2Eugene Kosov2019-06-231-1/+2
| | |\
| | | * MDEV-18661 loading the audit plugin causes performance regression.Alexey Botchkov2019-06-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Plugin fixed to not lock the LOCK_operations when not active. Server fixed to lock the LOCK_plugin less - do it once per thread and then only if a plugin was installed/uninstalled.
* | | | 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
| | | |\
| | | | * Update FSF addressMichal Schorm2019-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is based on the work of Michal Schorm, rebased on the earliest MariaDB version. Th command line used to generate this diff was: find ./ -type f \ -exec sed -i -e 's/Foundation, Inc., 59 Temple Place, Suite 330, Boston, /Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, /g' {} \; \ -exec sed -i -e 's/Foundation, Inc. 59 Temple Place.* Suite 330, Boston, /Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, /g' {} \; \ -exec sed -i -e 's/MA.*.....-1307.*USA/MA 02110-1335 USA/g' {} \; \ -exec sed -i -e 's/Foundation, Inc., 59 Temple/Foundation, Inc., 51 Franklin/g' {} \; \ -exec sed -i -e 's/Place, Suite 330, Boston, MA.*02111-1307.*USA/Street, Fifth Floor, Boston, MA 02110-1335 USA/g' {} \; \ -exec sed -i -e 's/MA.*.....-1307/MA 02110-1335/g' {} \;
* | | | | Move THD list handling to THD_listSergey Vojtovich2019-01-281-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented and integrated THD_list as a replacement for the global thread list. It uses own mutex instead of LOCK_thread_count for THD list protection. Removed unused first_global_thread() and next_global_thread(). delayed_insert_threads is now protected by LOCK_delayed_insert. Although this patch doesn't fix very wrong synchronization of this variable. After this patch there are only 2 legitimate uses of LOCK_thread_count left, both in mysqld.cc: thread_count and ready_to_exit. Aim is to reduce usage of LOCK_thread_count and COND_thread_count. Part of MDEV-15135.
* | | | Add likely/unlikely to speed up executionMonty2018-05-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-15356: tp_timeout_handler needs to call set_killed_no_mutex as it has ↵Daniel Black2018-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the mutex Regression introducted in c2118a08b144 where LOCK_thd_data was moveed to LOCK_thd_kill
* | | | remove ifdefs around PSI_THREAD_CALLSergei Golubchik2018-01-091-12/+4
| | | | | | | | | | | | | | | | same change as for PSI_TABLE_CALL
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-12-121-3/+3
|\ \ \ \
| * | | | Move all kill mutex protection to LOCK_thd_killMonty2017-12-081-3/+3
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LOCK_thd_data was used to protect both THD data and ensure that the THD is not deleted while it was in use This patch moves the THD delete protection to LOCK_thd_kill, which already protects the THD for kill. The benefits are: - More well defined what LOCK_thd_data protects - LOCK_thd_data usage is now much simpler and easier to verify - Less chance of deadlocks in SHOW PROCESS LIST as there is less chance of interactions between mutexes - Remove not needed LOCK_thread_count from thd_get_error_context_description() - Fewer mutex taken for thd->awake() Other things: - Don't take mysys->var mutex in show processlist to check if thread is kill marked - thd->awake() now automatically takes the LOCK_thd_kill mutex (Simplifies code) - Apc uses LOCK_thd_kill instead of LOCK_thd_data
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-09-011-1/+21
|\ \ \ \ | |/ / /
| * | | Fix threadpool to report connections aborted due to wait timeout.Vladislav Vaintroub2017-08-301-1/+21
| | | | | | | | | | | | | | | | Update wait_timeout.test to add test case for this.
* | | | Enusure that my_global.h is included firstMichael Widenius2017-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added sql/mariadb.h file that should be included first by files in sql directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables that must be done before my_global.h is included) - Removed a lot of include my_global.h from include files - Removed include's of some files that my_global.h automatically includes - Removed duplicated include's of my_sys.h - Replaced include my_config.h with my_global.h
* | | | Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3Alexander Barkov2017-04-031-1/+1
|\ \ \ \ | |/ / /
| * | | Merge branch '10.1' into 10.2Sergei Golubchik2017-03-301-1/+1
| |\ \ \ | | |/ /
| | * | Correct FSF addressiangilfillan2017-03-101-1/+1
| | | |
* | | | MDEV-11418 - AliSQL: [Feature] Issue#1 KILL IDLE TRANSACTIONSSergey Vojtovich2017-03-221-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Terminate idle transactions safely in server layer by setting up socket timeout parameter. Percona provides another patch to resolve similar problem, but it calls server layer's callback in InnoDB plugin to close THD, which crashes in some testcases. See https://bugs.launchpad.net/percona-server/+bug/901060 for more detailed information. 1. export parameter trx_idle_timeout to handle all kinds of transactions, the priority is highest 2. export parameter trx_readonly_idle_timeout to handle read-only transactions 3. export parameter trx_changes_idle_timeout to handle read-write transactions
* | | Merge branch '10.1' into 10.2Sergei Golubchik2016-12-291-39/+67
|\ \ \ | |/ /
| * | MDEV-11083 performance schema test fail with threadpoolVladislav Vaintroub2016-10-191-33/+66
| | | | | | | | | | | | Fix PSI idle and socket instrumentation in threadpool
* | | MDEV-10297 Add priorization to threadpoolVladislav Vaintroub2016-09-221-17/+197
| | | | | | | | | | | | Also MDEV-10385 Threadpool refactoring
* | | Merge branch '10.1' into 10.2Sergei Golubchik2016-09-091-2/+1
|\ \ \
| * | | MDEV-10314 : wsrep_client_thread was not set in threadpool.Vladislav Vaintroub2016-07-191-2/+1
| |/ / | | | | | | | | | | | | Fixed threadpool_add_connection to use thd_prepare_connection() to match thread-per-conection flow.
* | | cleanup: thread_countSergei Golubchik2016-06-041-1/+0
| | | | | | | | | | | | | | | | | | | | | move thread_count handling into THD: * increment thread_count in THD constructor * decrement thread_count in THD destructor * never modify thread_count directly!
* | | decrement thead_count *after* THD is destroyedSergei Golubchik2016-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | because thread_count means just that: number of THDs and shutdown code looks at it to know when to free shared data structures that THD uses. This fixes random crashes in ~THD on shutdown
* | | Reuse THD for new user connectionsMonty2016-06-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - To ensure that mallocs are marked for the correct THD, even if it's allocated in another thread, I added the thread_id to the THD constructor - Added st_my_thread_var to thr_lock_info_init() to avoid a call to my_thread_var - Moved things from THD::THD() to THD::init() - Moved some things to THD::cleanup() - Added THD::free_connection() and THD::reset_for_reuse() - Added THD to CONNECT::create_thd() - Added THD::thread_dbug_id and st_my_thread_var->dbug_id. These are needed to ensure that we have a constant thread_id used for debugging with a THD, even if it changes thread_id (=connection_id) - Set variables.pseudo_thread_id in constructor. Removed not needed sets.
* | | Fix leak from missing my_thread_endVladislav Vaintroub2016-03-091-16/+7
| | |
* | | Fix threadpool memory leak and connect2 testVladislav Vaintroub2016-03-091-1/+7
| | |
* | | Fix threadpool after it was broken by MDEV-6150Vladislav Vaintroub2016-03-081-9/+25
| | |
* | | Fix compilation10.2-sslVladislav Vaintroub2016-02-101-0/+13
| | |
* | | MDEV-6150 Speed up connection speed by moving creation of THD to new threadMonty2016-02-071-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Creating a CONNECT object on client connect and pass this to the working thread which creates the THD. Split LOCK_thread_count to different mutexes Added LOCK_thread_start to syncronize threads Moved most usage of LOCK_thread_count to dedicated functions Use next_thread_id() instead of thread_id++ Other things: - Thread id now starts from 1 instead of 2 - Added cast for thread_id as thread id is now of type my_thread_id - Made THD->host const (To ensure it's not changed) - Removed some DBUG_PRINT() about entering/exiting mutex as these was already logged by mutex code - Fixed that aborted_connects and connection_errors_internal are counted in all cases - Don't take locks for current_linfo when we set it (not needed as it was 0 before)
* | | Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2015-12-291-9/+15
|\ \ \ | |/ /
| * | MDEV-9156 : Fix tp_add_connection()'s error handlingVladislav Vaintroub2015-12-041-9/+15
| |/ | | | | | | Avoid possible my_thread_end() in the main polling thread.
* | MDEV-8715 - Obsolete sql_alloc() in favor of THD::alloc() and thd_alloc()Sergey Vojtovich2015-11-261-1/+0
|/ | | | | | | | | | | | | | The following left in semi-improved state to keep patch size reasonable: - Field operator new: left thd_alloc(current_thd) - Sql_alloc operator new: left thd_alloc(thd_get_current_thd()) - Item_args constructors: left thd_alloc(thd) - Item_func_interval::fix_length_and_dec(): no THD arg, have to call current_thd - Item_func_dyncol_exists::val_int(): same - Item_dyncol_get::val_str(): same - Item_dyncol_get::val_int(): same - Item_dyncol_get::val_real(): same - Item_dyncol_get::val_decimal(): same - Item_singlerow_subselect::fix_length_and_dec(): same
* MDEV-5205 - MariaDB does not start if more than 128 cpu's are availableSergey Vojtovich2013-11-051-0/+1
| | | | | | | | | | | - thread_pool_size command line option upper limit increased to 100 000 (same as for max_connections) - thread_pool_size system variable upper limit is maximum of 128 or the value given at command line - thread groups are now allocated dynamically Different limit for command line option and system variable was done to avoid additional mutex for all_groups and threadpool_max_size.
* MDEV-4685 Compile error on LFSSergei Golubchik2013-06-221-0/+8
| | | | fix the code to compile w/o perfomance schema
* MDEV-3945 - do not hold LOCK_thread_count when freeing THD.Vladislav Vaintroub2012-12-211-1/+0
| | | | | | | | | The patch decreases the duration of LOCK_thread_count, so it is not hold during THD destructor and freeing memory. This mutex now only protects the integrity of threads list, when removing THD from it, and thread_count variable. The add_to_status() function that updates global status during client disconnect, is now correctly protected by the LOCK_status mutex. Benchmark : in a "non-persistent" sysbench test (oltp_ro with reconnect after each query), ~ 25% more connects/disconnects were measured
* MDEV-531 : Warning: Forcing close of thread ... in rpl_binlog_indexVladislav Vaintroub2012-11-021-1/+1
| | | | | | Use post_kill_notification in for one_thread_per_connection scheduler, the same as already used in threadpool, to reliably wake a thread stuck in read() or in different poll() variations.
* MDEV-246 - Aborted_clients incremented during ordinary connection closeVladislav Vaintroub2012-05-031-1/+0
| | | | | | The problem was increment of aborted_threads variable due to thd->killed which was set when threadpool connection was terminated . The fix is not to set thd->killed anymore, there is no real reason for doing it.. Added a test that checks that status variable aborted_clients does not grow for ordinary disconnects, and that successful KILL increments this variable.
* Added copiright, some more commentsVladislav Vaintroub2012-02-171-0/+27
|
* address second round review commentsVladislav Vaintroub2012-02-161-9/+9
|
* Threadpool : Rest of monty's reviewVladislav Vaintroub2012-01-271-4/+0
|
* small cleanupsVladislav Vaintroub2012-01-241-0/+3
|