-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49995 from azat/dict/server-memory
Charge only server memory for dictionaries
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
32 changes: 32 additions & 0 deletions
32
tests/queries/0_stateless/02760_dictionaries_memory.sql.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- Tags: long | ||
-- Tag long: in parallel runs could exceed 60 seconds | ||
{# vim: ft=sql #} | ||
|
||
SET max_memory_usage=0; | ||
DROP DICTIONARY IF EXISTS dict; | ||
DROP TABLE IF EXISTS dict_data; | ||
|
||
CREATE TABLE dict_data (key UInt64, value UInt64) Engine=Memory(); | ||
INSERT INTO dict_data SELECT number, number%10 FROM numbers(3_000_000); | ||
|
||
SET max_memory_usage='4Mi'; | ||
{% for layout in [ | ||
'FLAT(INITIAL_ARRAY_SIZE 3_000_000 MAX_ARRAY_SIZE 3_000_000)', | ||
'HASHED()', | ||
'HASHED_ARRAY()', | ||
'SPARSE_HASHED()', | ||
'SPARSE_HASHED(SHARDS 2 /* shards are special, they use threads */)', | ||
] %} | ||
CREATE DICTIONARY dict (key UInt64, value UInt64) PRIMARY KEY key SOURCE(CLICKHOUSE(TABLE dict_data)) LIFETIME(0) LAYOUT({{layout}}); | ||
SYSTEM RELOAD DICTIONARY dict; | ||
-- assert that dictionary in memory takes more than 20MB, that way for each | ||
-- shard we will have 10MB, that way we ensure that the allocations will be | ||
-- definitely correct for the memory tracker to hit the MEMORY_LIMIT_EXCEEDED | ||
-- error. | ||
SELECT throwIf(bytes_allocated < 20e6, 'Memory constraints does not matched for layout {{layout}}') FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict' FORMAT Null; | ||
DROP DICTIONARY dict; | ||
|
||
CREATE DICTIONARY dict (key UInt64, value UInt64) PRIMARY KEY key SOURCE(CLICKHOUSE(TABLE dict_data)) LIFETIME(0) LAYOUT({{layout}}); | ||
SELECT dictGet('dict', 'value', 1::UInt64) FORMAT Null; | ||
DROP DICTIONARY dict; | ||
{% endfor %} |