Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix insert-select + insert_deduplication_token bug by setting streams to 1 #60745

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Interpreters/InterpreterInsertQuery.cpp
Expand Up @@ -513,6 +513,12 @@ BlockIO InterpreterInsertQuery::execute()
const bool resize_to_max_insert_threads = !table->isView() && views.empty();
pre_streams_size = resize_to_max_insert_threads ? settings.max_insert_threads
: std::min<size_t>(settings.max_insert_threads, pipeline.getNumStreams());

/// Deduplication when passing insert_deduplication_token breaks if using more than one thread
const String & deduplication_token = settings.insert_deduplication_token;
if (!deduplication_token.empty())
jrdi marked this conversation as resolved.
Show resolved Hide resolved
pre_streams_size = 1;
jrdi marked this conversation as resolved.
Show resolved Hide resolved

if (table->supportsParallelInsert())
sink_streams_size = pre_streams_size;
}
Expand Down
@@ -0,0 +1,2 @@
3
6
42 changes: 42 additions & 0 deletions tests/queries/0_stateless/03001_insert_threads_deduplication.sql
nickitat marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,42 @@
DROP TABLE IF EXISTS landing SYNC;
DROP TABLE IF EXISTS ds SYNC;

CREATE TABLE landing
(
timestamp DateTime64(3),
status String,
id String
)
ENGINE = MergeTree()
ORDER BY timestamp;

SYSTEM STOP MERGES landing; -- Stopping merges to force 3 parts

INSERT INTO landing (status, id, timestamp) SELECT * FROM generateRandom() LIMIT 1;
INSERT INTO landing (status, id, timestamp) SELECT * FROM generateRandom() LIMIT 1;
INSERT INTO landing (status, id, timestamp) SELECT * FROM generateRandom() LIMIT 1;

CREATE TABLE ds
(
timestamp DateTime64(3),
status String,
id String
)
ENGINE = MergeTree()
ORDER BY timestamp
SETTINGS non_replicated_deduplication_window=1000;

INSERT INTO ds SELECT * FROM landing
SETTINGS insert_deduplicate=1, insert_deduplication_token='token1',
max_insert_threads=5;

SELECT count() FROM ds;

INSERT INTO ds SELECT * FROM landing
SETTINGS insert_deduplicate=1, insert_deduplication_token='token2',
max_insert_threads=1;

SELECT count() FROM ds;

DROP TABLE IF EXISTS landing SYNC;
DROP TABLE IF EXISTS ds SYNC;