Skip to content

Commit 412ee03

Browse files
committed
Fix a memory leak on aborted InnoDB startup.
innodb_shutdown(), trx_sys_close(): Startup may be aborted between purge_sys and trx_sys creation. Therefore, purge_sys must be freed independently of trx_sys. innobase_start_or_create_for_mysql(): Remember to free purge_queue if it was not yet attached to purge_sys.
1 parent d35aea5 commit 412ee03

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

storage/innobase/srv/srv0start.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,7 @@ innobase_start_or_create_for_mysql(void)
22062206
DBUG_PRINT("ib_log", ("apply completed"));
22072207

22082208
if (err != DB_SUCCESS) {
2209+
UT_DELETE(purge_queue);
22092210
return(srv_init_abort(err));
22102211
}
22112212

@@ -2280,6 +2281,7 @@ innobase_start_or_create_for_mysql(void)
22802281
" a startup if you are trying to"
22812282
" recover a badly corrupt database.";
22822283

2284+
UT_DELETE(purge_queue);
22832285
return(srv_init_abort(DB_ERROR));
22842286
}
22852287
}
@@ -2796,6 +2798,9 @@ innodb_shutdown()
27962798
trx_sys_file_format_close();
27972799
trx_sys_close();
27982800
}
2801+
if (purge_sys) {
2802+
trx_purge_sys_close();
2803+
}
27992804
if (buf_dblwr) {
28002805
buf_dblwr_free();
28012806
}

storage/innobase/trx/trx0sys.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,10 +1092,6 @@ trx_sys_close(void)
10921092
trx_dummy_sess = NULL;
10931093
}
10941094

1095-
if (purge_sys) {
1096-
trx_purge_sys_close();
1097-
}
1098-
10991095
/* Only prepared transactions may be left in the system. Free them. */
11001096
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == trx_sys->n_prepared_trx
11011097
|| !srv_was_started

0 commit comments

Comments
 (0)