Dmitry Novik
a1f21a5fc4
Do not log peak for background memory tracker
2023-04-14 16:49:14 +02:00
Dmitry Novik
cf5d9a175a
Revert "Merge pull request #48760 from ClickHouse/revert-46089-background-memory-tracker"
...
This reverts commit a61ed33223
, reversing
changes made to 5f01b8a2b5
.
2023-04-14 16:34:19 +02:00
Alexander Tokmakov
af1bf08663
Revert "Add MemoryTracker for the background tasks"
2023-04-13 21:05:02 +03:00
Dmitry Novik
06e6794fc0
Merge remote-tracking branch 'origin/master' into background-memory-tracker
2023-04-11 15:29:35 +00:00
Azat Khuzhin
e91c8bfea3
Fix deadlock due to debug tracking of memory allocations
...
Since memory tracker should be blocked globally (by default it is blocked only
for VariableContext::User).
<details>
<summary>stacktrace</summary>
* thread 11, name = 'Collector', stop reason = trace
frame 1: 0x00007ffff7e37ea2 libc.so.6`pthread_mutex_lock + 274
frame 6: 0x000000001ee10298 clickhouse`toStringCached(pointers=0x00007fffedfef068, offset=0, size=45) + 88 at StackTrace.cpp:425
frame 7: 0x000000001ee1128e clickhouse`StackTrace::toString(this=0x00007fffedfef058) const + 46 at StackTrace.cpp:444
frame 8: 0x000000001ede58ff clickhouse`(anonymous namespace)::debugLogBigAllocationWithoutCheck(size=25187648) + 479 at MemoryTracker.cpp:98
frame 9: 0x000000001ede5481 clickhouse`MemoryTracker::allocImpl(this=0x0000000030729e68, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x00007ffff3c22440) + 3937 at MemoryTracker.cpp:352
frame 10: 0x000000001ede477f clickhouse`MemoryTracker::allocImpl(this=0x00007ffff3c1e530, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x00007ffff3c22440) + 607 at MemoryTracker.cpp:198
frame 11: 0x000000001ede477f clickhouse`MemoryTracker::allocImpl(this=0x00007ffff3c22440, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x0000000000000000) + 607 at MemoryTracker.cpp:198
frame 12: 0x000000001ede477f clickhouse`MemoryTracker::allocImpl(this=0x00007fffedff3bf0, size=25187648, throw_if_memory_exceeded=false, query_tracker=0x0000000000000000) + 607 at MemoryTracker.cpp:198
frame 13: 0x000000001ed6c4c9 clickhouse`CurrentMemoryTracker::allocImpl(size=25165824, throw_if_memory_exceeded=false) + 265 at CurrentMemoryTracker.cpp:58
frame 14: 0x000000001ed6c6a1 clickhouse`CurrentMemoryTracker::allocNoThrow(size=25165824) + 33 at CurrentMemoryTracker.cpp:91
frame 15: 0x000000001ed63079 clickhouse`operator new(unsigned long) [inlined] void Memory::trackMemory<>(size=25165824) + 89 at memory.h:177
frame 16: 0x000000001ed63034 clickhouse`operator new(size=25165824) + 20 at new_delete.cpp:74
...
frame 27: 0x000000001ee15895 clickhouse`DB::(anonymous namespace)::collectSymbols(info=0x00007ffff7062000, (null)=<unavailable>, data_ptr=0x00007fffec2b7000) + 53 at SymbolIndex.cpp:483
frame 28: 0x000000002e1a5d57 clickhouse`::dl_iterate_phdr(callback=(clickhouse`DB::(anonymous namespace)::collectSymbols(dl_phdr_info*, unsigned long, void*) at SymbolIndex.cpp:480), data=0x00007fffec2b7000)(dl_phdr_info *, size_t, void *), void *) + 183 at phdr_cache.cpp:76
frame 29: 0x000000001ee15549 clickhouse`DB::SymbolIndex::update(this=0x00007fffec2b7000) + 41 at SymbolIndex.cpp:515
frame 30: 0x000000001ee1be35 clickhouse`DB::SymbolIndex::SymbolIndex(this=<unavailable>) + 53 at SymbolIndex.h:23
frame 31: 0x000000001ee17a6c clickhouse`DB::SymbolIndex::instanceImpl() + 108 at SymbolIndex.cpp:555
frame 32: 0x000000001ee17b4a clickhouse`DB::SymbolIndex::instance() + 10 at SymbolIndex.cpp:561
frame 33: 0x000000001ee1070f clickhouse`void toStringEveryLineImpl<toStringCached(std::__1::array<void*, 45ul> const&, unsigned long, unsigned long)::$_0>(fatal=false, stack_trace=0x00007fffedff1ef8, callback=0x00007fffedff1ee0)::$_0&&) + 207 at StackTrace.cpp:349
frame 34: 0x000000001ee1040b clickhouse`toStringCached(pointers=0x00007fffedff2928, offset=0, size=43) + 459 at StackTrace.cpp:436
frame 35: 0x000000001ee1128e clickhouse`StackTrace::toString(this=0x00007fffedff2918) const + 46 at StackTrace.cpp:444
frame 36: 0x000000001ede58ff clickhouse`(anonymous namespace)::debugLogBigAllocationWithoutCheck(size=25165824) + 479 at MemoryTracker.cpp:98
frame 37: 0x000000001ede5481 clickhouse`MemoryTracker::allocImpl(this=0x00007fffedff3bf0, size=25165824, throw_if_memory_exceeded=false, query_tracker=0x0000000000000000) + 3937 at MemoryTracker.cpp:352
frame 38: 0x000000001ed6c4c9 clickhouse`CurrentMemoryTracker::allocImpl(size=25165824, throw_if_memory_exceeded=false) + 265 at CurrentMemoryTracker.cpp:58
frame 39: 0x000000001ed6c6a1 clickhouse`CurrentMemoryTracker::allocNoThrow(size=25165824) + 33 at CurrentMemoryTracker.cpp:91
frame 40: 0x000000001ed63079 clickhouse`operator new(unsigned long) [inlined] void Memory::trackMemory<>(size=25165824) + 89 at memory.h:177
frame 41: 0x000000001ed63034 clickhouse`operator new(size=25165824) + 20 at new_delete.cpp:74
...
frame 55: 0x0000000025badace clickhouse`DB::WriteBufferFromS3::nextImpl(this=0x00007ffff3c58f00) + 366 at WriteBufferFromS3.cpp:110
</details>
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-04-06 16:03:46 +02:00
Sema Checherinda
b8729be97a
Merge pull request #47104 from CheSema/thead-group-for-merge
...
merge and mutation make thread group for setting memory trackers right
2023-04-06 15:46:56 +02:00
Alexander Tokmakov
0e0e89d596
fix
2023-04-05 15:10:09 +02:00
Alexander Tokmakov
f5574d0d74
find big allocations without limits checks
2023-04-04 20:10:22 +02:00
Sema Checherinda
a6ab33a906
no use query, but storage context
2023-03-27 16:30:32 +02:00
Sema Checherinda
da4f2bd923
do not attach empty thread group
2023-03-24 19:53:16 +01:00
Sema Checherinda
bc107c70fa
merge and mutation make thread group for setting memory trackers right
2023-03-24 19:53:16 +01:00
Alexander Tokmakov
d621b2c4ad
fix intersecting parts, better fault injections
2023-03-16 21:28:07 +01:00
Dmitry Novik
1e065b32f3
Add MemoryTracker for the background tasks
2023-02-06 17:25:58 +00:00
Dmitry Novik
ec1f6bfd37
Improve MEMERY_LIMIT_EXCEEDED exception message
2023-01-29 01:52:37 +00:00
Alexander Tokmakov
70d1adfe4b
Better formatting for exception messages ( #45449 )
...
* save format string for NetException
* format exceptions
* format exceptions 2
* format exceptions 3
* format exceptions 4
* format exceptions 5
* format exceptions 6
* fix
* format exceptions 7
* format exceptions 8
* Update MergeTreeIndexGin.cpp
* Update AggregateFunctionMap.cpp
* Update AggregateFunctionMap.cpp
* fix
2023-01-24 00:13:58 +03:00
Raúl Marín
948ce8db93
Revert "Merge pull request #38953 from ClickHouse/add-allocation-ptr-to-trace-log"
...
This reverts commit e99849d031
, reversing
changes made to 7ad3ff8a9e
.
2022-12-27 14:28:13 +01:00
Nikolai Kochetov
9a4b3493fd
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-12-06 17:09:54 +01:00
Nikolai Kochetov
7649a3c4d7
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-12-01 12:12:23 +01:00
Anton Popov
312dd725b4
allow to send profile events to trace_log
2022-11-24 20:12:16 +00:00
Dmitry Novik
b17dc24a94
Do not reuse jemalloc memory in test
2022-11-21 16:10:47 +00:00
Azat Khuzhin
7b69a70e82
Fix frequent memory drift message and clarify things in comments
...
Somethine like:
2022.09.28 06:33:34.001433 [ 3133669 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 562.20 MiB, peak 562.21 MiB, will set to 562.20 MiB (RSS), difference: -70.46 MiB
2022.09.28 06:33:35.001639 [ 3133669 ] {} <Trace> AsynchronousMetrics: MemoryTracking: was 562.20 MiB, peak 562.21 MiB, will set to 562.20 MiB (RSS), difference: -70.45 MiB
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-10-26 17:38:37 +02:00
Azat Khuzhin
f5f6f1b593
Add profile events for jemalloc purge
...
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-10-26 17:38:36 +02:00
Robert Schulze
fd86829824
Consolidate config_core.h into config.h
...
Less duplication, less confusion ...
2022-09-28 13:31:57 +00:00
Nikolai Kochetov
9e1bb19559
Purge jemalloc arenas in case of high memory usage. ( #40277 )
...
* Purge jemalloc arenas in case of high memory usage.
* Purge jemalloc arenas in case of high memory usage.
* Get RSS before jemalloc counters. Try to avoid negative RSS.
* Try to avoid negative RSS.
* muzzy -> dirty
* Another fix.
* Update MemoryTracker.cpp
* Wait for purged memory.
* Revert "Wait for purged memory."
This reverts commit 53a2621a2d
.
2022-09-20 23:56:10 +02:00
Alexey Milovidov
fa62c7e982
Fix half of trash
2022-09-10 04:08:16 +02:00
Azat Khuzhin
28f2607d50
Fix rare race in updating peak of memory tracker
...
Previously it was possible that allocation, that had been done with
locked MEMORY_LIMIT_EXCEEDED (LockMemoryExceptionInThread), will update
the peak to the amount that will include some other allocations.
Consider the following example (T1/T2 - different threads):
Initial state:
MemoryTracker::amount = 0
Possible race:
LockMemoryExceptionInThread locker;
T1: MemoryTracker::allocImpl(1MiB) T2: MemoryTracker::allocImpl(1PiB)
will_be = 1T, amount = 1T
will_be = 1T+1MiB, amount=1T+1MiB
peak = will_be
amount = 0 // revert due to exceeding limit
throw(MEMORY_LIMIT_EXCEEDED)
So as you can see T1 includes allocations from T2 into the peak.
Note, that almost every place that has memory_usage column uses
MemoryTracker::peak (not MemoryTracker::amount), this is true for
query_log (for part_log column name is peak_memory_usage, and obviously
it uses MemoryTracker::peak).
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-08-19 20:57:12 +02:00
Azat Khuzhin
ded70fbd53
Fix memory accounting in case of MEMORY_LIMIT_EXCEEDED errors
...
In case of memory allocation had been failed, it should not be take into
account anywhere, otherwise it will report incorrect memory usage for
query and in logs.
I found this while was digging into OOM in stress tests, and saw memory
allocations that had been significantly greater the memory limit (even
with overcommit).
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-08-16 18:08:56 +02:00
Nikita Mikhaylov
2282f2f414
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-08-15 12:25:45 +02:00
Alexey Milovidov
216c1d8efa
Revert "Use separate counter for RSS in global memory tracker."
2022-08-14 09:50:12 +03:00
Nikita Mikhaylov
00d2c57a68
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-08-12 13:32:24 +02:00
Nikita Mikhaylov
8e8e845a89
Merge branch 'master' into separate-counter-for-rss-in-memory-tracker
2022-08-10 16:44:24 +02:00
Nikita Mikhaylov
f144eae388
Fix typo and extra dots in exception messages from OverCommitTracker ( #39858 )
2022-08-03 15:23:07 +02:00
Nikolai Kochetov
fa0707b4e7
Review fixes.
2022-07-26 17:51:09 +00:00
Nikolai Kochetov
fc6982f9e2
Fixing test.
2022-07-19 10:10:02 +00:00
Nikolai Kochetov
5a3cb07711
Fix rss
2022-07-18 21:24:41 +00:00
Nikolai Kochetov
3ee3144708
Merge branch 'master' into separate-counter-for-rss-in-memory-tracker
2022-07-18 23:20:38 +02:00
Nikolai Kochetov
87e5b31598
Do not include memory buffered by allocator into drift.
2022-07-18 21:16:16 +00:00
Nikolai Kochetov
8b56695073
Review fixes.
2022-07-08 14:46:11 +00:00
Nikolai Kochetov
c8b1d840ba
Fixing build.
2022-07-07 15:49:15 +00:00
Nikolai Kochetov
0f231b8641
Merge branch 'master' into add-allocation-ptr-to-trace-log
2022-07-07 16:30:49 +02:00
Alexander Tokmakov
fdd2db4ace
Move check for denied allocations ( #38858 )
...
* move check for denied allocations
* remove include
* make hardening softer
2022-07-07 14:24:36 +02:00
Nikolai Kochetov
dcdf2e4527
Track allocation ptr in system.trace_log. Add aggregate function for flamegraph.
2022-07-07 11:54:41 +00:00
Alexey Milovidov
02adad3f27
Merge pull request #37860 from amosbird/remove-duplicated-log
...
Remove duplicate peak mem log
2022-07-07 08:16:06 +03:00
Nikolai Kochetov
b7529986c0
Use separate counter for RSS in global memory tracker.
2022-07-01 12:09:32 +00:00
Dmitry Novik
53d656d89f
Fix deadlock in OvercommitTracker logging
2022-06-20 17:35:24 +00:00
Amos Bird
a5afb73c52
Remove duplicated peak mem log
...
Also log "Processed in {} sec" a little bit earlier so that it's also
sent to client and have the log entry related to the query_id.
2022-06-05 17:02:58 +08:00
Dmitry Novik
60b9d81773
Remove global_memory_usage_overcommit_max_wait_microseconds
2022-05-27 16:30:29 +00:00
Dmitry Novik
e9187ec4b7
Overcommit: update defaults, exception message and add ProfileEvent
2022-05-23 14:35:09 +00:00
Dmitry Novik
a97ba9741e
Fix possible deadlock in OvercommitTracker during logging
2022-05-17 18:07:52 +00:00
Dmitry Novik
2ed5a4013a
Revert "Revert "Memory overcommit: continue query execution if memory is available""
2022-05-03 00:45:13 +02:00