Commit graph

49 commits

Author SHA1 Message Date
Monty
74543698a7 MDEV-13179 main.errors fails with wrong errno
The problem was that the introduction of max-thread-mem-used can cause
an allocation error very early, even before mysql_parse() is called.
As mysql_parse() calls thd->reset_for_next_command(), which called
clear_error(), the error number was lost.

Fixed by adding an option to have unique messages for each KILL
signal and change max-thread-mem-used to use this new feature.
This removes a lot of problems with the original approach, where
one could get errors signaled silenty almost any time.

ixed by moving clear_error() from reset_for_next_command() to
do_command(), before any memory allocation for the thread.

Related changes:
- reset_for_next_command() now have an optional parameter if we should
  call clear_error() or not. By default it's called, but not anymore from
  dispatch_command() which was the original problem.
- Added optional paramater to clear_error() to force calling of
  reset_diagnostics_area(). Before clear_error() only called
  reset_diagnostics_area() if there was no error, so we normally
  called reset_diagnostics_area() twice.
- This change removed several duplicated calls to clear_error()
  when starting a query.
- Reset max_mem_used on COM_QUIT, to protect against kill during
  quit.
- Use fatal_error() instead of setting is_fatal_error (cleanup)
- Set fatal_error if max_thead_mem_used is signaled.
  (Same logic we use for other places where we are out of resources)
2017-08-07 03:48:58 +03:00
Sergei Golubchik
9e11e055ce Merge branch '10.0' into 10.1 2017-07-07 11:30:03 +02:00
Sergei Golubchik
89dc445a55 Merge branch '5.5' into 10.0 2017-07-06 23:47:33 +02:00
Daniel Black
623c3f6731 thread_group_close: release mutex in all branches
Found by Coverity scan - id 92087
2017-07-03 12:51:30 +04:00
iangilfillan
f0ec34002a Correct FSF address 2017-03-10 18:21:29 +01:00
Sergei Golubchik
c081c978a2 Merge branch '5.5' into bb-10.0 2016-06-21 14:11:02 +02:00
Sergey Vojtovich
2db724c8d2 MDEV-10218 - rpl.rpl_binlog_errors fails in buildbot with valgrind warnings -
bytes are possibly lost

Timer thread of threadpool is created "joinable", but they're not "joined" on
completion. This causes memory leaks around thread local storage.

Fixed by joining timer thread.
2016-06-13 16:05:45 +04:00
Vladislav Vaintroub
50160216ea MDEV-9156 : Fix tp_add_connection()'s error handling
Avoid possible my_thread_end() in the main polling thread.
2015-12-04 18:16:04 +01:00
Oleksandr Byelkin
0ce0b88080 MDEV-8450: PATCH] Wrong macro expansion in Query_cache::send_result_to_client()
Expression in macro protected by ()
2015-09-06 22:26:33 +02:00
Alexander Barkov
57cdc561fc Fixing AIX compilation failires 2014-02-27 19:44:00 +04:00
unknown
55de9b0468 merge 10-base->10.0 2013-11-11 23:40:53 +02:00
Sergey Vojtovich
a588de1fe8 MDEV-5205 - MariaDB does not start if more than 128 cpu's are available
An addition to fix for MDEV-5205, fixes server crash on shutdown.

Thread groups are destroyed asynchronously, that is kill server
thread sends shutdown request to all thread groups without waiting
for compeltion.

It means all_groups array must not be freed until all thread groups
are down. This patch suggests that all_groups is freed when last
thread group is destroyed.

Note 1: threadpool code doesn't surround atomic ops with atomic locks,
thus no locks for shutdown_group_count.
Note 2: this patch preserves old behaviour, but we may need to wait
until all thread groups are down before returning from tp_end().
2013-11-06 22:53:39 +04:00
Sergey Vojtovich
fd9f1638ea MDEV-5205 - MariaDB does not start if more than 128 cpu's are available
- 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.
2013-11-05 09:18:59 +04:00
Sergei Golubchik
5f6380adde 10.0-base merge 2013-07-18 16:46:57 +02:00
Sergei Golubchik
7c61679c4e MDEV-4685 Compile error on LFS
fix the code to compile w/o perfomance schema
2013-06-22 14:02:03 +02:00
Sergei Golubchik
72ba95873a 10.0-base merge
(without InnoDB - all InnoDB changes were ignored)
2013-06-06 21:32:29 +02:00
Vladislav Vaintroub
ef1e767ae3 MDEV-4553 - Fixes for compilation under NetBSD. 2013-05-27 16:35:42 +02:00
Sergei Golubchik
a9035be5b7 10.0-base merge 2013-04-15 15:09:22 +02:00
Vladislav Vaintroub
2c37ace131 MDEV-4174 - Use kqueue for threadpool implementation on more BSD variants than just FreeBSD
or OSX - i.e NetBSD, OpenBSD, DragonFly, etc.
2013-02-19 23:46:52 +01:00
Vladislav Vaintroub
1701ee3357 MDEV-4113: Assertion (group->connection_count > 0) fails with Percona server in replication test.
Assertion happens in replication thread during THD destruction, when thread calls my_sync(), which in turn calls  thd_wait_begin() callback. Connection count can be 0, because the counter was decremented before THD destructor. 
This assertion currently reproducible only in Percona server  and not in MariaDB, due to differences in replication code.

Fixed by moving  code to decrement connection counter after the THD destructor.
2013-01-30 17:25:02 +01:00
Sergei Golubchik
40e94a3734 merge with 5.5 2012-11-03 12:28:51 +01:00
Vladislav Vaintroub
4ffc9c3b01 MDEV-531 : Warning: Forcing close of thread ... in rpl_binlog_index
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.
2012-11-02 10:43:52 +01:00
Michael Widenius
60589aeee0 Next part of merge. See TODO for details 2012-08-14 17:23:34 +03:00
Vladislav Vaintroub
85a025f30c Threadpool - use EV_ONESHOT with kevent, to prevent race condition when 2
threads are retrieving events at the same time.
2012-04-12 01:40:44 +02:00
Vladislav Vaintroub
2a5d8ea9a2 Added copiright, some more comments 2012-02-17 23:27:15 +01:00
Vladislav Vaintroub
cfa56f900a address second round review comments 2012-02-16 16:59:04 +01:00
Vladislav Vaintroub
4d1c7b7947 some more whitespace, remove pending_thread_start_count. increment counters (thread_group->count, thread_group->active_thread_count) whenever mysql_create_thread returns success. 2012-01-28 01:09:28 +01:00
Vladislav Vaintroub
804f3bfeaf Threadpool : Rest of monty's review 2012-01-27 19:52:53 +01:00
Vladislav Vaintroub
57b6cb39aa Further review points and simplify Windows implementation 2012-01-26 04:35:54 +01:00
Vladislav Vaintroub
d50649ecf7 small cleanups 2012-01-24 03:23:14 +01:00
Vladislav Vaintroub
c492296127 ensure that lock is held, whenever active thread counter changes.
It was not the case inside listener routine.
2012-01-18 21:12:04 +01:00
Vladislav Vaintroub
6909311028 Threadpool : address some of the monty's review points
Also, print message when pool blocks.
2012-01-17 18:50:40 +01:00
Vladislav Vaintroub
1f8cbf168c Fix threadpool on BSD and Solaris 2012-01-16 02:18:24 +01:00
Vladislav Vaintroub
d212991e89 Get rid of idle thread counter atomic variable.
Instead, use function that loops over groups and 
calculates  idle threads for  "show status".
2012-01-15 15:41:25 +01:00
Vladislav Vaintroub
18c9b345b4 Threadpool -address review comments 2012-01-15 11:17:45 +01:00
Vladislav Vaintroub
c216c9f0f0 Allow for faster creation of threads in corner cases where pool would be overloaded with long non-yielding queries.
To allow it, change minimum of thread_pool_stall_limit to be 10 milliseconds.

Also introduce a new parameter to oversubscribe a group . Number of threads running in  parallel would be higher than it normally should, leading to thrashing, but it may improving preemptiveness, which is useful for the described corner case.
2011-12-31 05:24:11 +01:00
Vladislav Vaintroub
bb0a0c52a6 Make threadpool_stall_limit variable really dynamic 2011-12-29 21:11:06 +01:00
Vladislav Vaintroub
539a7ebe10 LP909537: Ensure thd_wait_begin/thd_wait_end callbacks are called. 2011-12-29 19:37:26 +01:00
Vladislav Vaintroub
bee1d88abf LP909512: Fix crash on tp_set_threadpool_size if threadpool is not used(thread_handling != pool-of-threads) 2011-12-29 12:53:07 +01:00
Vladislav Vaintroub
b9f2fb84f6 Fix LP#909414: Valgrind warnings in threadpool code 2011-12-29 12:17:30 +01:00
Vladislav Vaintroub
54b61b8b44 LP9091416: destroy timer mutex when threadpool scheduler shuts down.
Fixes valgrind warning.
2011-12-29 01:59:05 +01:00
Vladislav Vaintroub
ecad00bc4e use performance-schema friendly mysql_thread_create() instead of pthread_create() 2011-12-28 16:23:46 +01:00
Vladislav Vaintroub
7da4229f2e Fix build on old 32 bit Centos (kernel 2.6.18) 2011-12-26 01:08:46 +01:00
Vladislav Vaintroub
96041f8e1d make sys_vars suite pass 2011-12-20 22:49:24 +01:00
Vladislav Vaintroub
df48c9bf20 allow changing thread_pool_size without server restart 2011-12-19 13:28:30 +01:00
Vladislav Vaintroub
2e4bde4c0f Fix pool_of_threads test case 2011-12-18 23:03:35 +01:00
Vladislav Vaintroub
a5a22e9f64 Small adjustements to threadpool 2011-12-18 20:40:38 +01:00
Vladislav Vaintroub
c439494942 Fix Unix build 2011-12-10 19:35:44 +01:00
Vladislav Vaintroub
e91bbca5fb Initial threadpool implementation for MariaDB 5.5 2011-12-08 19:17:49 +01:00