Skip to content

Commit

Permalink
Backport 5.7 Fix of Bug#18253089 BUF_POOL->FLUSH_RBT IS CREATED WHEN …
Browse files Browse the repository at this point in the history
…RECOVERY IS NOT NEEDED, THEN NEVER FREED

Summary:
Backport the following patch from 5.7 to fix bootstrap failure in ASAN builds.

  commit 30a08cf
  Author: Vasil Dimov <[email protected]>
  Date:   Thu May 15 05:07:12 2014

    Fix Bug#18253089 BUF_POOL->FLUSH_RBT IS CREATED WHEN RECOVERY IS NOT NEEDED,
    THEN NEVER FREED

    * recv_recovery_from_checkpoint_start() is only called from
      innobase_start_or_create_for_mysql() and
      recv_recovery_from_checkpoint_start() calls recv_sys_create()&recv_sys_init()
      but those two functions have already been called earlier in
      innobase_start_or_create_for_mysql(). Those two functions return immediately
      if recv_sys is created/initialized. From this follows that their invokations
      from recv_recovery_from_checkpoint_start() are noops and thus I am removing
      them.

    * The code used to initialize buf_pool->flush_rbt (buf_flush_init_flush_rbt())
      from recv_sys_init(). Change this so that it is initialized directly from
      recv_recovery_from_checkpoint_start(). This is the only functional change
      in this patch - buf_pool->flush_rbt will now be initialized later in the
      startup code path.

    * The code used to free buf_pool->flush_rbt (buf_flush_free_flush_rbt()) from
      recv_sys_debug_free(). Change this so that the free is done from
      recv_recovery_from_checkpoint_finish(), which is the only caller of
      recv_sys_debug_free(). This is a noop, but made for consistency wrt where
      alloc/free is done - call
      buf_flush_init_flush_rbt() from recv_recovery_from_checkpoint_start() and
      buf_flush_free_flush_rbt() from recv_recovery_from_checkpoint_finish().

    This way the code will be restored as of before
    [email protected] (the fix of
    Bug#18144349 INNODB CANNOT USE THE DOUBLEWRITE BUFFER FOR THE FIRST PAGE OF
    SYSTEM TABLESPACE) wrt buf_pool->flush_rbt initialization.

    Approved by:    Yasufumi (rb:5409)

Reviewed By: gunnarku

Differential Revision: D5180536

fbshipit-source-id: a293320
  • Loading branch information
tianx authored and facebook-github-bot committed Jun 4, 2017
1 parent cb92ca6 commit fefc12e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ buf_flush_init_flush_rbt(void)

buf_flush_list_mutex_enter(buf_pool);

ut_ad(buf_pool->flush_rbt == NULL);

/* Create red black tree for speedy insertions in flush list. */
buf_pool->flush_rbt = rbt_create(
sizeof(buf_page_t*), buf_flush_block_cmp);
Expand Down
17 changes: 8 additions & 9 deletions storage/innobase/log/log0recv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,6 @@ recv_sys_init(
}

#ifndef UNIV_HOTBACKUP
/* Initialize red-black tree for fast insertions into the
flush_list during recovery process.
As this initialization is done while holding the buffer pool
mutex we perform it before acquiring recv_sys->mutex. */
buf_flush_init_flush_rbt();

mutex_enter(&(recv_sys->mutex));

recv_sys->heap = mem_heap_create_typed(256,
Expand Down Expand Up @@ -487,9 +481,6 @@ recv_sys_debug_free(void)
recv_sys->last_block_buf_start = NULL;

mutex_exit(&(recv_sys->mutex));

/* Free up the flush_rbt. */
buf_flush_free_flush_rbt();
}
# endif /* UNIV_LOG_DEBUG */

Expand Down Expand Up @@ -3084,6 +3075,11 @@ recv_recovery_from_checkpoint_start_func(
byte* log_hdr_buf;
byte log_hdr_mem[LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE];
dberr_t err;

/* Initialize red-black tree for fast insertions into the
flush_list during recovery process. */
buf_flush_init_flush_rbt();

ut_when_dtor<recv_dblwr_t> tmp(recv_sys->dblwr);

log_hdr_buf = (byte*)ut_align(log_hdr_mem, OS_FILE_LOG_BLOCK_SIZE);
Expand Down Expand Up @@ -3510,6 +3506,9 @@ recv_recovery_from_checkpoint_finish(void)
#ifndef UNIV_LOG_DEBUG
recv_sys_debug_free();
#endif
/* Free up the flush_rbt. */
buf_flush_free_flush_rbt();

/* Roll back any recovered data dictionary transactions, so
that the data dictionary tables will be free of any locks.
The data dictionary latch should guarantee that there is at
Expand Down

0 comments on commit fefc12e

Please sign in to comment.