Bug #103210 | InnoDB index cardinality stats are racy | ||
---|---|---|---|
Submitted: | 5 Apr 2021 21:07 | Modified: | 7 Apr 2021 5:24 |
Reporter: | Manuel Ung | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 8.0.23 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[5 Apr 2021 21:07]
Manuel Ung
[5 Apr 2021 22:22]
Manuel Ung
I just noticed that https://bugs.mysql.com/bug.php?id=82968 is pretty much the same issue, but it's closed?
[6 Apr 2021 6:24]
Øystein Grøvlen
Is this the same as Bug#98132?
[6 Apr 2021 10:09]
MySQL Verification Team
Thank you, Øystein. Hello Manuel Ung, Thank you for the report and feedback. As Øystein pointed, this seems to be the same as reported in Bug #98132. If you have no objections then I'll mark this as a duplicate of Bug #98132. Please confirm! regards, Umesh
[6 Apr 2021 19:45]
Manuel Ung
I don't think the problem is exactly the same and I don't think the suggested fix there will fix this issue. In #98132, we seem to persisting the incorrect stats because we end up analyzing a table that is still being rebuilt. In this case, we don't persist the incorrect stats and there's no DDL, and it's just a race condition where we read out bad stats temporarily while an analyze is happening, but the stats will be correct after the analyze finishes.
[6 Apr 2021 20:06]
Øystein Grøvlen
I agree with Manuel that this is not quite the same problem as Bug#98132.
[6 Apr 2021 20:10]
Øystein Grøvlen
A possible solution is to let dict_stats_analyze_index() use a private copy for the statistics gathering, and replace the old statistics when the the new statistics have been computed.
[7 Apr 2021 5:24]
MySQL Verification Team
Thank you, Manual and Øystein. regards, Umesh
[11 May 2024 3:14]
WANG GUANGYOU
hi Manuel, I add this in the test case you provide set debug_sync = "after_empty_index SIGNAL parked WAIT_FOR go"; send analyze table t; connect (con1,localhost,root,,); set information_schema_stats_expiry = 0; set debug_sync='now WAIT_FOR parked'; show indexes in t; +set session eq_range_index_dive_limit=0; +explain select b,c,d from t where b = 1 and c=1 and d = 1 ; although ths index statistics looks not good. but the SQL choose the right plan. So the race condition really hurt performance? set session eq_range_index_dive_limit=0; explain select b,c,d from t where b = 1 and c=1 and d = 1 ; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t NULL ref abc abc 15 const,const,const 1 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t`.`b` AS `b`,`test`.`t`.`c` AS `c`,`test`.`t`.`d` AS `d` from `test`.`t` where ((`test`.`t`.`d` = 1) and (`test`.`t`.`c` = 1) and (`test`.`t`.`b` = 1))
[11 May 2024 3:30]
WANG GUANGYOU
btw, I test on 8.0.36 percona version