未验证 提交 ad8c9f88 编写于 作者: A alesapin 提交者: GitHub

Merge pull request #4396 from yandex/attach-memory-limit-exceeded

Avoid "Memory limit exceeded" during ATTACH TABLE query
......@@ -460,6 +460,11 @@ void MergeTreeDataPart::makeCloneInDetached(const String & prefix) const
void MergeTreeDataPart::loadColumnsChecksumsIndexes(bool require_columns_checksums, bool check_consistency)
{
/// Memory should not be limited during ATTACH TABLE query.
/// This is already true at the server startup but must be also ensured for manual table ATTACH.
/// Motivation: memory for index is shared between queries - not belong to the query itself.
auto temporarily_disable_memory_tracker = getCurrentMemoryTrackerActionLock();
loadColumns(require_columns_checksums);
loadChecksums(require_columns_checksums);
loadIndex();
......
DROP TABLE IF EXISTS test.index_memory;
CREATE TABLE test.index_memory (x UInt64) ENGINE = MergeTree ORDER BY x SETTINGS index_granularity = 1;
INSERT INTO test.index_memory SELECT * FROM system.numbers LIMIT 10000000;
SELECT count() FROM test.index_memory;
DETACH TABLE test.index_memory;
SET max_memory_usage = 79000000;
ATTACH TABLE test.index_memory;
SELECT count() FROM test.index_memory;
DROP TABLE test.index_memory;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册