Skip to content

Commit b653b11

Browse files
Herman Leefacebook-github-bot
Herman Lee
authored andcommitted
Fix crash in InnoDB persistent stats update for almost empty tables
Summary: When tables are near empty and innodb tries to recalculate stats for them, there seems to be a possibility the analyze_level code can return with total_recs == 0, even though there are assertions around total_recs cannot be 0. Add a check in the level analyze code to break out early of total_recs returned is 0. Reviewed By: tianx Differential Revision: D5541154 fbshipit-source-id: 76a1aba
1 parent f1265d6 commit b653b11

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: storage/innobase/dict/dict0stats.cc

+8
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,14 @@ dict_stats_analyze_index(
21962196

21972197
ut_ad(N_SAMPLE_PAGES(index) > 0);
21982198

2199+
/* There looks to be a possibility total_recs is 0 if the tree
2200+
* only consists of delete rows, causing
2201+
* dict_stats_analyze_index_for_n_prefix() to trigger a crash.
2202+
* Bail out at this point if total_recs is 0. */
2203+
if (total_recs == 0) {
2204+
break;
2205+
}
2206+
21992207
n_diff_data_t* data = &n_diff_data[n_prefix - 1];
22002208

22012209
data->level = level;

0 commit comments

Comments
 (0)