Skip to content

Commit

Permalink
Fix bug 1578139 (Parallel doublewrite memory not freed with innodb_fa…
Browse files Browse the repository at this point in the history
…st_shutdown=2)

With a very fast InnoDB shutdown, buf_parallel_dblwr_destroy(), which
closes and deletes the doublewrite file and frees memory, is skipped.
In this configuration the file should not be deleted, thus fix by
renaming buf_parallel_dblwr_destroy() to buf_parallel_dblwr_free()
that unconditionally frees memory and, depending on the arg value,
closes and deletes the file. Call it in the common code path for all
innodb_fast_shutdown values.
  • Loading branch information
laurynas-biveinis committed May 6, 2016
1 parent dba9967 commit 8a53ed7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
19 changes: 11 additions & 8 deletions storage/innobase/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ buf_parallel_dblwr_file_create(void)
success = os_file_set_size(parallel_dblwr_buf.path,
parallel_dblwr_buf.file, size, false);
if (!success) {
buf_parallel_dblwr_destroy();
buf_parallel_dblwr_free(true);
return(DB_ERROR);
}
ut_ad(os_file_get_size(parallel_dblwr_buf.file) == size);
Expand Down Expand Up @@ -1567,7 +1567,7 @@ buf_parallel_dblwr_create(void)
* UNIV_PAGE_SIZE,
mem_key_parallel_doublewrite));
if (!dblwr_shard->write_buf_unaligned) {
buf_parallel_dblwr_destroy();
buf_parallel_dblwr_free(true);
return(DB_OUT_OF_MEMORY);
}
dblwr_shard->write_buf = static_cast<byte*>(
Expand All @@ -1579,7 +1579,7 @@ buf_parallel_dblwr_create(void)
* sizeof(void*),
mem_key_parallel_doublewrite));
if (!dblwr_shard->buf_block_arr) {
buf_parallel_dblwr_destroy();
buf_parallel_dblwr_free(true);
return(DB_OUT_OF_MEMORY);
}

Expand All @@ -1591,10 +1591,11 @@ buf_parallel_dblwr_create(void)
return(DB_SUCCESS);
}

/** Close and delete the doublewrite buffer file and free its memory data
structure. */
/** Cleanup parallel doublewrite memory structures and optionally close and
delete the doublewrite buffer file too.
@param delete_file whether to close and delete the buffer file too */
void
buf_parallel_dblwr_destroy(void)
buf_parallel_dblwr_free(bool delete_file)
{
for (ulint i = 0; i < buf_parallel_dblwr_shard_num(); i++) {

Expand All @@ -1610,8 +1611,10 @@ buf_parallel_dblwr_destroy(void)
ut_free(dblwr_shard->buf_block_arr);
}

buf_parallel_dblwr_close();
buf_parallel_dblwr_delete();
if (delete_file) {
buf_parallel_dblwr_close();
buf_parallel_dblwr_delete();
}

ut_free(parallel_dblwr_buf.path);
parallel_dblwr_buf.path = NULL;
Expand Down
7 changes: 4 additions & 3 deletions storage/innobase/include/buf0dblwr.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ computed. It is up to the caller to ensure that this called at safe point */
void
buf_parallel_dblwr_delete(void);

/** Close and delete the doublewrite buffer file and free its memory data
structure. */
/** Cleanup parallel doublewrite memory structures and optionally close and
delete the doublewrite buffer file too.
@param delete_file whether to close and delete the buffer file too */
void
buf_parallel_dblwr_destroy(void);
buf_parallel_dblwr_free(bool delete_file);

/** Release any unused parallel doublewrite pages and free their underlying
buffer at the end of crash recovery */
Expand Down
2 changes: 0 additions & 2 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2405,8 +2405,6 @@ logs_empty_and_mark_files_at_shutdown(void)
fil_write_flushed_lsn(lsn);
}

buf_parallel_dblwr_destroy();

fil_close_all_files();

/* Make some checks that the server really is quiet */
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/trx/trx0sys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ trx_sys_close(void)

/* Free the double write data structures. */
buf_dblwr_free();
buf_parallel_dblwr_free(srv_fast_shutdown != 2);

/* Only prepared transactions may be left in the system. Free them. */
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == trx_sys->n_prepared_trx);
Expand Down

0 comments on commit 8a53ed7

Please sign in to comment.