Commit Graph

85 Commits

Author SHA1 Message Date
Alexey Milovidov
28ded4a471
Merge pull request #63632 from azat/global-query-profiler-followup
Ignore global profiler if system.trace_log is not enabled and fix really disable it for keeper standalone build
2024-05-20 08:42:25 +02:00
Antonio Andelic
d4b3581792 Allow allocation during job data destructor call 2024-05-15 12:08:16 +02:00
Azat Khuzhin
4ad88d04b4 Move initGlobalProfiler() into ThreadStatusExt.cpp and fix examples
To avoid undefined references in examples:

    May 11 01:58:40 ld.lld-17: error: undefined symbol: DB::Context::hasTraceCollector() const
    May 11 01:58:40 >>> referenced by ThreadStatus.cpp:132 (/build/src/Common/ThreadStatus.cpp:132)
    May 11 01:58:40 >>>               ThreadStatus.cpp.o:(DB::ThreadStatus::initGlobalProfiler(unsigned long, unsigned long)) in archive src/libclickhouse_common_iod.a
    May 11 01:58:40 clang++-17: error: linker command failed with exit code 1 (use -v to see invocation)

Move it firstly into ThreadStatusExt and then do not try to use it from
the ThreadPool.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-05-13 11:05:36 +02:00
Alexander Tokmakov
e1646165c8 fix backups 2024-04-10 23:08:25 +02:00
Alexander Tokmakov
d8e97b51bf Merge branch 'master' into cannot_allocate_thread 2024-04-10 21:21:42 +02:00
Alexander Tokmakov
5db9fbed52 cancel tasks on exception 2024-04-04 22:32:57 +02:00
Alexander Tokmakov
c53b20a770 fix 2024-04-03 20:57:12 +02:00
Alexander Tokmakov
98ac8031e0 add fault injection 2024-04-03 19:49:23 +02:00
alesapin
f5c5146153 [RFC] Try to add global Real and CPU trace collector 2024-04-02 18:04:53 +02:00
Azat Khuzhin
cc296a1b8a Move some code of ThreadPool into module part
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-12-27 17:06:17 +01:00
Azat Khuzhin
55d5a3affa Correctly wait background threads
There are some places that make it possible to trigger use-after-free
from threads because some global variable had been destroyed before, for
example some logger.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-12-09 17:54:16 +01:00
Alexey Milovidov
d56cbda185 Add metrics for the number of queued jobs, which is useful for the IO thread pool 2023-11-18 19:07:59 +01:00
Alexey Milovidov
aa757490bd Ditch tons of garbage 2023-08-09 02:19:02 +02:00
Yakov Olkhovskiy
8854f05a75 style fix 2023-06-28 19:53:49 +00:00
Yakov Olkhovskiy
6e769237a7 added setting 'enable_job_stack_trace', default is off 2023-06-28 01:39:06 +00:00
Yakov Olkhovskiy
be17a81792 recursively collect call stacks on job scheduling and add all stack traces to exceptions printout 2023-06-24 00:12:31 +00:00
Sergei Trifonov
0d1f2e297b
Unify priorities: lower value means higher priority (#50205) 2023-05-26 15:55:30 +02:00
Anton Popov
223adc1725 fix ThreadPool::wait 2023-05-05 19:14:45 +00:00
serxa
22b75ec81b fix typo, add coment, dont reset trace 2023-04-13 15:17:39 +00:00
serxa
32f78afd7e get rid of redundant code 2023-04-13 12:11:06 +00:00
serxa
ce2073e58f detach_thread() and notifications order does not matter 2023-04-13 11:45:19 +00:00
serxa
5e8339c2d9 Lock ThreadPool mutex once per job instead of twice 2023-04-13 11:27:11 +00:00
Alexey Milovidov
e982fb9f1c
Merge pull request #47880 from azat/threadpool-introspection
ThreadPool metrics introspection
2023-03-30 01:27:31 +03:00
Frank Chen
87d235e842
Some improvements about names of span logs (#47667) 2023-03-29 16:28:36 +02:00
Azat Khuzhin
f38a7aeabe ThreadPool metrics introspection
There are lots of thread pools and simple local-vs-global is not enough
already, it is good to know which one in particular uses threads.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-03-29 10:46:59 +02:00
Vitaly Baranov
4318212c73 Make a condition more clear. 2023-03-21 21:52:59 +01:00
Vitaly Baranov
096d0132af More corrections. 2023-03-21 21:52:59 +01:00
Vitaly Baranov
0a0e9d060f Corrections after review. 2023-03-21 21:52:59 +01:00
Vitaly Baranov
85d38493f6 Improve ThreadPool
ThreadPool::setMaxThreads() can now start new threads (if there are scheduled jobs in the queue for them);
ThreadPool::setMaxFreeThreads() can now finish free threads.
2023-03-21 21:52:59 +01:00
Anton Popov
839cd614fb fix memory leak in azure sdk 2023-01-31 01:01:10 +00:00
Zhiguo Zhou
823cb8a8f0 Call std::condition_variable::notify_one w/o lock in ThreadPool
Calling notify_one function with lock held would let the notified
thread immediately block again, and increase the lock contention.
This commit moves the calls of notify_one function out of critical
sections of ThreadPool, whose lock (ThreadPoolImpl::mutex) is most
extensively contended in some workloads.
2022-12-21 13:50:03 +08:00
Azat Khuzhin
4e76629aaf Fixes for -Wshorten-64-to-32
- lots of static_cast
- add safe_cast
- types adjustments
  - config
  - IStorage::read/watch
  - ...
- some TODO's (to convert types in future)

P.S. That was quite a journey...

v2: fixes after rebase
v3: fix conflicts after #42308 merged
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-10-21 13:25:19 +02:00
Frank Chen
d9a516288c Resolve comments 2022-09-01 11:56:10 +08:00
Frank Chen
83cbdef3c6 Fix context re-initialization for ThreadPool 2022-08-30 12:26:23 +08:00
Frank Chen
92f7ca3616 Move TracingContextOnThread::current() out of class for simplicity
Signed-off-by: Frank Chen <frank.chen021@outlook.com>
2022-08-25 20:23:56 +08:00
Frank Chen
bb00dcc19b Remove using namespace from header
Signed-off-by: Frank Chen <frank.chen021@outlook.com>
2022-08-25 20:20:13 +08:00
Frank Chen
03007606ba Fix format
Signed-off-by: Frank Chen <frank.chen021@outlook.com>
2022-08-24 17:01:31 +08:00
Frank Chen
cd19366b44 Move classes into DB::OpenTelemetry namespace 2022-08-24 16:41:40 +08:00
Frank Chen
efc6a60a60 Clean code 2022-08-24 15:59:44 +08:00
Frank Chen
035896fa16 Fix build check 2022-08-02 20:18:42 +08:00
Frank Chen
da57a993e4 Fix CI 2022-07-09 13:43:10 +08:00
Frank Chen
93dc109e36 Fix code 2022-07-07 17:44:19 +08:00
Frank Chen
32931857f0 Propagate tracing context across threads 2022-07-07 17:41:43 +08:00
Robert Schulze
f692ead6ad
Don't use std::unique_lock unless we have to
Replace where possible by std::lock_guard which is more light-weight.
2022-06-28 19:19:06 +00:00
Robert Schulze
b24ca8de52
Fix various clang-tidy warnings
When I tried to add cool new clang-tidy 14 warnings, I noticed that the
current clang-tidy settings already produce a ton of warnings. This
commit addresses many of these. Almost all of them were non-critical,
i.e. C vs. C++ style casts.
2022-04-20 10:29:05 +02:00
Alexey Milovidov
ab80b94f45
Update ThreadPool.cpp 2022-04-13 15:18:49 +03:00
Alexey Milovidov
f0fad98a73 Reset thread name in thread pool 2022-04-11 01:03:24 +02:00
alexey-milovidov
a089f9918c
Update ThreadPool.cpp 2022-02-04 03:54:33 +03:00
Alexey Milovidov
78eebd5c7c Fix parallel loading of data parts 2022-02-04 02:29:46 +03:00
Tomáš Hromada
445b0ba7cc
Expose all GlobalThreadPool config params (#31285) 2021-11-12 16:24:47 +03:00