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

enable-async-apply-prewrite = true, query result is incorrect with index merge #52901

Open
seiya-annie opened this issue Apr 26, 2024 · 3 comments

Comments

@seiya-annie
Copy link

seiya-annie commented Apr 26, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

cluster-a:
tidb:
config: |
max-index-length = 12287
new_collations_enabled_on_first_bootstrap = true
[experimental]
allow-expression-index = true
tikv:
config: |
[storage]
reserve-space = 0
enable-async-apply-prewrite = true
[pessimistic-txn]
pipelined = true
in-memory = true

cluster-b:
tikv:
config: |
[storage]
reserve-space = "0MB"
tidb:
config: |
max-index-length = 12287
new_collations_enabled_on_first_bootstrap = true
[experimental]
allow-expression-index = true

the default value of "enable-async-apply-prewrite" is false.

create table tbl_43 ( col_304 binary(207) collate binary default 'eIenHx' not null , primary key idx_258 ( col_304 ) , unique key idx_259 ( col_304(5) ) , unique key idx_260 ( col_304(2) ) , key idx_261 ( col_304 ) , unique key idx_262 ( col_304 ) ) collate utf8_bin;
 replace into tbl_43  values ( 'BCmuENPHzSOIMJLPB' ) , ( 'TloTqcHhdgpwvMsSoJ' ) , ( 'LDOdXZYpOR') , ( 'UajN' ) , ( 'mAwLZbiyq' ) , ( 'R' ) , ( 'swLIoWa' );
 select max( col_304 ) from (select  /*+ use_index_merge( tbl_43 ) */ * from tbl_43 where not( tbl_43.col_304 between 'YEpfYfPVvhMlHGHSMKm' and 'PE' ) or tbl_43.col_304 in ( 'LUBGzGMA' ) and tbl_43.col_304 between 'HpsjfuSReCwBoh' and 'fta' or not( tbl_43.col_304 between 'MFWmuOsoyDv' and 'TSeMYpDXnFIyp' ) order by col_304  )  ordered_tbl  ;

2. What did you expect to see? (Required)

the result should be same in two clusters

3. What did you see instead (Required)

in cluster-a:

mysql> select max( col_304 ) from (select  /*+ use_index_merge( tbl_43 ) */ * from tbl_43 where not( tbl_43.col_304 between 'YEpfYfPVvhMlHGHSMKm' and 'PE' ) or tbl_43.col_304 in ( 'LUBGzGMA' ) and tbl_43.col_304 between 'HpsjfuSReCwBoh' and 'fta' or not( tbl_43.col_304 between 'MFWmuOsoyDv' and 'TSeMYpDXnFIyp' ) order by col_304  )  ordered_tbl  ;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| max( col_304 )                                                                                                                                                                                                                                                                                                                                                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x42436D75454E50487A534F494D4A4C504200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

in cluster-b:

mysql> select max( col_304 ) from (select  /*+ use_index_merge( tbl_43 ) */ * from tbl_43 where not( tbl_43.col_304 between 'YEpfYfPVvhMlHGHSMKm' and 'PE' ) or tbl_43.col_304 in ( 'LUBGzGMA' ) and tbl_43.col_304 between 'HpsjfuSReCwBoh' and 'fta' or not( tbl_43.col_304 between 'MFWmuOsoyDv' and 'TSeMYpDXnFIyp' ) order by col_304  )  ordered_tbl  ;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| max( col_304 )                                                                                                                                                                                                                                                                                                                                                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 0x73774C496F57610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)

results are same for below sqls:
select /*+ use_index_merge( tbl_43 ) */ * from tbl_43 where not( tbl_43.col_304 between 'YEpfYfPVvhMlHGHSMKm' and 'PE' ) or tbl_43.col_304 in ( 'LUBGzGMA' ) and tbl_43.col_304 between 'HpsjfuSReCwBoh' and 'fta' or not( tbl_43.col_304 between 'MFWmuOsoyDv' and 'TSeMYpDXnFIyp' ) order by col_304 ;
select max( col_304 ) from tbl_43;
select * from tbl_43;

4. What is your TiDB version? (Required)

tidb: e8c397f
tikv: af169fc72dada426c9952200db1d6322ab7990e9

@seiya-annie seiya-annie added the type/bug This issue is a bug. label Apr 26, 2024
@seiya-annie
Copy link
Author

seiya-annie commented Apr 26, 2024

cluster-a:
截屏2024-04-26 11 33 03
cluster-b:
截屏2024-04-26 11 32 26

@seiya-annie
Copy link
Author

截屏2024-04-26 11 41 20
截屏2024-04-26 11 42 04

@AilinKid
Copy link
Contributor

#52947

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

No branches or pull requests

4 participants