mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
fix memory leak during index calculation
This commit is contained in:
parent
59bffda932
commit
5448bf7b86
@ -331,9 +331,6 @@ void MergeTreeDataPartWriterOnDisk::calculateAndSerializePrimaryIndex(const Bloc
|
||||
if (!metadata_snapshot->hasPrimaryKey())
|
||||
return;
|
||||
|
||||
if (index_columns.empty())
|
||||
index_columns = primary_index_block.cloneEmptyColumns();
|
||||
|
||||
{
|
||||
/** While filling index (index_columns), disable memory tracker.
|
||||
* Because memory is allocated here (maybe in context of INSERT query),
|
||||
@ -343,6 +340,9 @@ void MergeTreeDataPartWriterOnDisk::calculateAndSerializePrimaryIndex(const Bloc
|
||||
*/
|
||||
MemoryTrackerBlockerInThread temporarily_disable_memory_tracker;
|
||||
|
||||
if (index_columns.empty())
|
||||
index_columns = primary_index_block.cloneEmptyColumns();
|
||||
|
||||
/// Write index. The index contains Primary Key value for each `index_granularity` row.
|
||||
for (const auto & granule : granules_to_write)
|
||||
{
|
||||
@ -434,9 +434,10 @@ void MergeTreeDataPartWriterOnDisk::fillPrimaryIndexChecksums(MergeTreeData::Dat
|
||||
{
|
||||
MemoryTrackerBlockerInThread temporarily_disable_memory_tracker;
|
||||
calculateAndSerializePrimaryIndexRow(last_index_block, last_index_block.rows() - 1);
|
||||
last_index_block.clear();
|
||||
}
|
||||
|
||||
last_index_block.clear();
|
||||
|
||||
if (compress_primary_key)
|
||||
{
|
||||
index_source_hashing_stream->finalize();
|
||||
|
@ -0,0 +1 @@
|
||||
150000
|
@ -0,0 +1,15 @@
|
||||
-- Tags: no-debug, no-tsan, no-msan, no-asan, no-random-settings, no-random-merge-tree-settings
|
||||
|
||||
DROP TABLE IF EXISTS t_primary_index_memory;
|
||||
CREATE TABLE t_primary_index_memory (s String) ENGINE = MergeTree
|
||||
ORDER BY s SETTINGS index_granularity = 1;
|
||||
|
||||
INSERT INTO t_primary_index_memory SELECT repeat('a', 10000) FROM numbers(150000)
|
||||
SETTINGS
|
||||
max_block_size = 32,
|
||||
max_memory_usage = '100M',
|
||||
max_insert_block_size = 1024,
|
||||
min_insert_block_size_rows = 1024;
|
||||
|
||||
SELECT count() FROM t_primary_index_memory;
|
||||
DROP TABLE t_primary_index_memory;
|
Loading…
Reference in New Issue
Block a user