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

[Bug] Sql cache return wrong result #23548

Closed
3 tasks done
dutyu opened this issue Aug 28, 2023 · 2 comments · Fixed by #23555
Closed
3 tasks done

[Bug] Sql cache return wrong result #23548

dutyu opened this issue Aug 28, 2023 · 2 comments · Fixed by #23555

Comments

@dutyu
Copy link
Contributor

dutyu commented Aug 28, 2023

Search before asking

  • I had searched in the issues and found no similar issues.

Version

all version

What's Wrong?

When enable query sql cache, if we delete some partition(s), the cache will not be refreshed and the query will return wrong result.

What You Expected?

Query cache should return right result.

How to Reproduce?

  1. At fe.conf, set cache_last_version_interval_second=0, cache_enable_sql_mode=true, then set session variable set enable_sql_cache=true, and create a table like this:
CREATE TABLE `tbl_test` (
  `siteid` int(11) NOT NULL DEFAULT "10",
  `citycode` smallint(6) NOT NULL DEFAULT "0",
  `username` varchar(32) NOT NULL DEFAULT "",
  `pday` varchar(20) NOT NULL DEFAULT "",
  `pv` bigint(20) SUM NOT NULL DEFAULT "0",
  INDEX siteid_Idx (`siteid`) USING BITMAP COMMENT '创建表加siteid列索引'
) ENGINE=OLAP
AGGREGATE KEY(`siteid`, `citycode`, `username`, `pday`)
PARTITION BY LIST(`pday`)
(
    PARTITION `p_20230825` VALUES IN ("20230825"),
    PARTITION `p_20230826` VALUES IN ("20230826"),
    PARTITION `p_20230827` VALUES IN ("20230827")
)
DISTRIBUTED BY HASH(`siteid`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);    
  1. insert some data:
insert into `tbl_test` values(1, 1, 'test', '20230825', 1);
insert into `tbl_test` values(1, 1, 'test', '20230826', 1);
insert into `tbl_test` values(1, 1, 'test', '20230827', 1);
  1. execute a query: select * from tbl_test, it will return 3 rows.
  2. delete partition p_20230826 by executing alter table tbl_test drop partition p_20230826.
  3. execute this query again: select * from tbl_test, it will return 3 rows too (in fact the right result should be 2, the row in partition p_20230826 should not be returned).

image

Anything Else?

The reason is that sql cache just use partitionKey , latestVersion and latestTime to check if the cache should be returned, if we delete some partition(s) which is not the latest updated partition, the all above values are not changed, so the cache will hit.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@nimuyuhan
Copy link
Contributor

Test the master branch code and the problem cannot be repeated.The cache_last_version_interval_second variable does not exist.

@dutyu
Copy link
Contributor Author

dutyu commented Aug 28, 2023

Test the master branch code and the problem cannot be repeated.The cache_last_version_interval_second variable does not exist.

Oh, this is a FE configuration, set these configurations cache_last_version_interval_second=0, cache_enable_sql_mode=true at fe.conf, and set session variable by executing set enable_sql_cache=true to enable sql cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants