Fix mutation of StorageMemory

fix

fix
This commit is contained in:
feng lv 2021-05-19 08:56:08 +00:00
parent 98e6c27a95
commit d92b1f0e9a
3 changed files with 40 additions and 1 deletions

View File

@ -262,7 +262,14 @@ void StorageMemory::mutate(const MutationCommands & commands, ContextPtr context
auto metadata_snapshot = getInMemoryMetadataPtr();
auto storage = getStorageID();
auto storage_ptr = DatabaseCatalog::instance().getTable(storage, context);
auto interpreter = std::make_unique<MutationsInterpreter>(storage_ptr, metadata_snapshot, commands, context, true);
/// When max_threads > 1, the order of returning blocks is uncentain,
/// which will lead to inconsistency after updateBlockData.
auto new_context = Context::createCopy(context);
new_context->setSetting("max_streams_to_max_threads_ratio", 1);
new_context->setSetting("max_threads", 1);
auto interpreter = std::make_unique<MutationsInterpreter>(storage_ptr, metadata_snapshot, commands, new_context, true);
auto in = interpreter->execute();
in->readPrefix();

View File

@ -0,0 +1,32 @@
DROP TABLE IF EXISTS mem_test;
CREATE TABLE mem_test
(
`a` Int64,
`b` Int64
)
ENGINE = Memory;
SET max_block_size = 3;
INSERT INTO mem_test SELECT
number,
number
FROM numbers(100);
ALTER TABLE mem_test
UPDATE a = 0 WHERE b = 99;
ALTER TABLE mem_test
UPDATE a = 0 WHERE b = 99;
ALTER TABLE mem_test
UPDATE a = 0 WHERE b = 99;
ALTER TABLE mem_test
UPDATE a = 0 WHERE b = 99;
ALTER TABLE mem_test
UPDATE a = 0 WHERE b = 99;
SELECT *
FROM mem_test
FORMAT Null;
DROP TABLE mem_test;