Skip to content

Commit d52c9bf

Browse files
luqunfacebook-github-bot
authored andcommitted
Fix memory leak in i_s_innodb_tablespaces_fill_table (#1380)
Summary: Looks like when space is 0, we forgot to release memory. Following innodb code, after finish works, then call release heap memory at end Pull Request resolved: #1380 Test Plan: MTR under asan build Differential Revision: D50746754 fbshipit-source-id: cb7f7d4c420df3fbb2a7ab28c477cbec92a095a7
1 parent 2c299ad commit d52c9bf

File tree

1 file changed

+3
-8
lines changed
  • storage/innobase/handler

1 file changed

+3
-8
lines changed

storage/innobase/handler/i_s.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7108,14 +7108,13 @@ static int i_s_innodb_tablespaces_fill_table(THD *thd, TABLE_LIST *tables,
71087108
heap = mem_heap_create(1000);
71097109

71107110
if (dd_access_through_server()) {
7111-
return for_all_innodb_objects_in_dd<dd::Tablespace>(
7111+
int result = for_all_innodb_objects_in_dd<dd::Tablespace>(
71127112
thd, [&heap, &tables](THD *thd, const dd::Tablespace &tablespace) {
71137113
const auto &se_private_data = tablespace.se_private_data();
71147114

71157115
space_id_t space;
71167116
if (se_private_data.get(dd_space_key_strings[DD_SPACE_ID], &space)) {
71177117
assert(false);
7118-
mem_heap_free(heap);
71197118
return 1;
71207119
}
71217120

@@ -7132,15 +7131,13 @@ static int i_s_innodb_tablespaces_fill_table(THD *thd, TABLE_LIST *tables,
71327131
if (se_private_data.get(dd_space_key_strings[DD_SPACE_FLAGS],
71337132
&flags)) {
71347133
assert(false);
7135-
mem_heap_free(heap);
71367134
return 1;
71377135
}
71387136

71397137
dd::String_type encryption;
71407138
if (properties.exists("encryption") &&
71417139
properties.get("encryption", &encryption)) {
71427140
assert(false);
7143-
mem_heap_free(heap);
71447141
return 1;
71457142
}
71467143

@@ -7155,15 +7152,13 @@ static int i_s_innodb_tablespaces_fill_table(THD *thd, TABLE_LIST *tables,
71557152
if (se_private_data.get(dd_space_key_strings[DD_SPACE_SERVER_VERSION],
71567153
&server_version)) {
71577154
assert(false);
7158-
mem_heap_free(heap);
71597155
return 1;
71607156
}
71617157

71627158
uint32 space_version;
71637159
if (se_private_data.get(dd_space_key_strings[DD_SPACE_VERSION],
71647160
&space_version)) {
71657161
assert(false);
7166-
mem_heap_free(heap);
71677162
return 1;
71687163
}
71697164

@@ -7172,15 +7167,13 @@ static int i_s_innodb_tablespaces_fill_table(THD *thd, TABLE_LIST *tables,
71727167
if (se_private_data.get(dd_space_key_strings[DD_SPACE_STATE],
71737168
&state)) {
71747169
assert(false);
7175-
mem_heap_free(heap);
71767170
return 1;
71777171
}
71787172

71797173
uint64_t autoextend_size = 0;
71807174
if (properties.exists(autoextend_size_str) &&
71817175
properties.get(autoextend_size_str, &autoextend_size)) {
71827176
assert(false);
7183-
mem_heap_free(heap);
71847177
return 1;
71857178
}
71867179

@@ -7192,6 +7185,8 @@ static int i_s_innodb_tablespaces_fill_table(THD *thd, TABLE_LIST *tables,
71927185

71937186
return 0;
71947187
});
7188+
mem_heap_free(heap);
7189+
return result;
71957190
}
71967191

71977192
assert(!dd_access_through_server());

0 commit comments

Comments
 (0)