apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.63k stars 3.26k forks source link

[Bug] Inconsistent query results about dulplicate key model #35148

Open zhaorongsheng opened 5 months ago

zhaorongsheng commented 5 months ago

Search before asking

Version

2.0.9

What's Wrong?

ddl:

CREATE TABLE `test_tbl` (
  `logtime` int(11) NULL,
  `userid` bigint(20) NULL,
  `col1` varchar(128) NULL,
  `col2` varchar(128) NULL,
  `col3` varchar(512) NULL,
  `col4` varchar(256) NULL,
  `col5` varchar(256) NULL,
  `col6` varchar(256) NULL,
  `col7` text NULL,
  `col8` varchar(512) NULL,
  `dt` date NULL,
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=OLAP
DUPLICATE KEY(`logtime`, `userid`, `col1`, `col2`, `col3`)
COMMENT 'OLAP'
PARTITION BY RANGE(`dt`)
(PARTITION p20240514 VALUES [('2024-05-14'), ('2024-05-15')),
PARTITION p20240515 VALUES [('2024-05-15'), ('2024-05-16')),
PARTITION p20240516 VALUES [('2024-05-16'), ('2024-05-17')),
PARTITION p20240517 VALUES [('2024-05-17'), ('2024-05-18')),
PARTITION p20240518 VALUES [('2024-05-18'), ('2024-05-19')),
PARTITION p20240519 VALUES [('2024-05-19'), ('2024-05-20')),
PARTITION p20240520 VALUES [('2024-05-20'), ('2024-05-21')),
PARTITION p20240521 VALUES [('2024-05-21'), ('2024-05-22')),
PARTITION p20240522 VALUES [('2024-05-22'), ('2024-05-23')),
PARTITION p20240523 VALUES [('2024-05-23'), ('2024-05-24')),
PARTITION p20240524 VALUES [('2024-05-24'), ('2024-05-25')))
DISTRIBUTED BY RANDOM BUCKETS 800
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"is_being_synced" = "false",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.start" = "-7",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"dynamic_partition.replication_allocation" = "tag.location.default: 3",
"dynamic_partition.buckets" = "800",
"dynamic_partition.create_history_partition" = "true",
"dynamic_partition.history_partition_num" = "-1",
"dynamic_partition.hot_partition_num" = "0",
"dynamic_partition.reserved_history_periods" = "NULL",
"dynamic_partition.storage_policy" = "",
"storage_format" = "V2",
"compression" = "ZSTD",
"light_schema_change" = "true",
"compaction_policy" = "time_series",
"time_series_compaction_goal_size_mbytes" = "1024",
"time_series_compaction_file_count_threshold" = "2000",
"time_series_compaction_time_threshold_seconds" = "3600",
"time_series_compaction_empty_rowsets_threshold" = "5",
"time_series_compaction_level_threshold" = "1",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);

query history partition data:

select count(1) from test_tbl where dt='2024-05-19';

The results of the same sql are different for each time.

image

When set use_fix_replica = 1, the results are the same and the results of use_fix_replica = 1 and use_fix_replica = 2 are different.

At the same time, the tablet healthy monitor is normal and all tablets' state is healthy.

image

What You Expected?

The tablet health monitor should display the inconsistent replicas if they exists.

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

dataroaring commented 5 months ago

Could you save result of fix_replica 1 and 2 into two tables, and query a query on two tables to find different rows?

dataroaring commented 5 months ago

Please add some predicates to the sql, e.g. where dt between, to narrow down the scope of the problem.

huukhuongnguyen commented 2 months ago

I also encountered a similar issue, have you found a solution yet?

zhaorongsheng commented 1 month ago

I also encountered a similar issue, have you found a solution yet?

We fixed the problem by set use_fix_replica = 0;. It may be caused by "Version Incomplete" tablets .