Describe the bug
Insert the same data to ReplicatedMergeTree table but get only one record when select.
How to reproduce
Create table
CREATE TABLE olap.replicated_test
(
date Date,
a String,
b String
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/replicated_test', '{replica}')
PARTITION BY toYYYYMM(date)
ORDER BY (date, a, b)
SETTINGS index_granularity = 8192;
Insert data and select
insert into olap.replicated_test values('2020-06-01', 'a', 'b');
select * from olap.replicated_test;
ββββββββdateββ¬βaββ¬βbββ
β 2020-06-01 β a β b β
ββββββββββββββ΄ββββ΄ββββ
Insert the same data again and select
insert into olap.replicated_test values('2020-06-01', 'a', 'b');
select * from olap.replicated_test;
ββββββββdateββ¬βaββ¬βbββ
β 2020-06-01 β a β b β
ββββββββββββββ΄ββββ΄ββββ
That's how insert deduplication works.
https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/replication/
_Data blocks are deduplicated. For multiple writes of the same data block (data blocks of the same size containing the same rows in the same order), the block is only written once. The reason for this is in case of network failures when the client application doesnβt know if the data was written to the DB, so the INSERT query can simply be repeated. It doesnβt matter which replica INSERTs were sent to with identical data. INSERTs are idempotent. Deduplication parameters are controlled by merge_tree server settings._
https://clickhouse.tech/docs/en/operations/settings/settings/#settings-insert-deduplicate
Most helpful comment
That's how insert deduplication works.
https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/replication/
_Data blocks are deduplicated. For multiple writes of the same data block (data blocks of the same size containing the same rows in the same order), the block is only written once. The reason for this is in case of network failures when the client application doesnβt know if the data was written to the DB, so the INSERT query can simply be repeated. It doesnβt matter which replica INSERTs were sent to with identical data. INSERTs are idempotent. Deduplication parameters are controlled by merge_tree server settings._
https://clickhouse.tech/docs/en/operations/settings/settings/#settings-insert-deduplicate