Commit 859714e7 authored by Marko Mäkelä's avatar Marko Mäkelä

Simplify up InnoDB redo log system startup and shutdown

recv_sys_init(): Remove the parameter.

recv_sys_create(): Merge to recv_sys_init().

recv_sys_mem_free(): Merge to recv_sys_close().

log_mem_free(): Merge to log_shutdown().
parent 8143ef1b
...@@ -407,16 +407,9 @@ Closes all log groups. */ ...@@ -407,16 +407,9 @@ Closes all log groups. */
void void
log_group_close_all(void); log_group_close_all(void);
/*=====================*/ /*=====================*/
/********************************************************//** /** Shut down the redo log subsystem. */
Shutdown the log system but do not release all the memory. */
void
log_shutdown(void);
/*==============*/
/********************************************************//**
Free the log system data structures. */
void void
log_mem_free(void); log_shutdown();
/*==============*/
/** Whether to generate and require checksums on the redo log pages */ /** Whether to generate and require checksums on the redo log pages */
extern my_bool innodb_log_checksums; extern my_bool innodb_log_checksums;
......
...@@ -81,27 +81,12 @@ recv_reset_logs( ...@@ -81,27 +81,12 @@ recv_reset_logs(
OS_FILE_LOG_BLOCK_SIZE, after OS_FILE_LOG_BLOCK_SIZE, after
which we add which we add
LOG_BLOCK_HDR_SIZE */ LOG_BLOCK_HDR_SIZE */
/********************************************************//** /** Clean up after recv_sys_init() */
Creates the recovery system. */
void
recv_sys_create(void);
/*=================*/
/**********************************************************//**
Release recovery system mutexes. */
void
recv_sys_close(void);
/*================*/
/********************************************************//**
Frees the recovery system memory. */
void void
recv_sys_mem_free(void); recv_sys_close();
/*===================*/ /** Initialize the redo log recovery subsystem. */
/********************************************************//**
Inits the recovery system for a recovery operation. */
void void
recv_sys_init( recv_sys_init();
/*==========*/
ulint available_memory); /*!< in: available memory in bytes */
/********************************************************//** /********************************************************//**
Frees the recovery system. */ Frees the recovery system. */
void void
......
...@@ -2261,11 +2261,9 @@ log_group_close_all(void) ...@@ -2261,11 +2261,9 @@ log_group_close_all(void)
log_group_close(&log_sys->log); log_group_close(&log_sys->log);
} }
/********************************************************//** /** Shut down the redo log subsystem. */
Shutdown the log system but do not release all the memory. */
void void
log_shutdown(void) log_shutdown()
/*==============*/
{ {
log_group_close_all(); log_group_close_all();
...@@ -2289,20 +2287,8 @@ log_shutdown(void) ...@@ -2289,20 +2287,8 @@ log_shutdown(void)
} }
recv_sys_close(); recv_sys_close();
} ut_free(log_sys);
log_sys = NULL;
/********************************************************//**
Free the log system data structures. */
void
log_mem_free(void)
/*==============*/
{
if (log_sys != NULL) {
recv_sys_mem_free();
ut_free(log_sys);
log_sys = NULL;
}
} }
/******************************************************//** /******************************************************//**
......
...@@ -415,31 +415,9 @@ fil_name_parse( ...@@ -415,31 +415,9 @@ fil_name_parse(
return(end_ptr); return(end_ptr);
} }
/********************************************************//** /** Clean up after recv_sys_init() */
Creates the recovery system. */
void
recv_sys_create(void)
/*=================*/
{
if (recv_sys != NULL) {
return;
}
recv_sys = static_cast<recv_sys_t*>(ut_zalloc_nokey(sizeof(*recv_sys)));
mutex_create(LATCH_ID_RECV_SYS, &recv_sys->mutex);
mutex_create(LATCH_ID_RECV_WRITER, &recv_sys->writer_mutex);
recv_sys->heap = NULL;
recv_sys->addr_hash = NULL;
}
/********************************************************//**
Release recovery system mutexes. */
void void
recv_sys_close(void) recv_sys_close()
/*================*/
{ {
if (recv_sys != NULL) { if (recv_sys != NULL) {
recv_sys->dblwr.pages.clear(); recv_sys->dblwr.pages.clear();
...@@ -578,56 +556,41 @@ DECLARE_THREAD(recv_writer_thread)( ...@@ -578,56 +556,41 @@ DECLARE_THREAD(recv_writer_thread)(
OS_THREAD_DUMMY_RETURN; OS_THREAD_DUMMY_RETURN;
} }
/************************************************************ /** Initialize the redo log recovery subsystem. */
Inits the recovery system for a recovery operation. */
void void
recv_sys_init( recv_sys_init()
/*==========*/
ulint available_memory) /*!< in: available memory in bytes */
{ {
if (recv_sys->heap != NULL) { ut_ad(recv_sys == NULL);
return; recv_sys = static_cast<recv_sys_t*>(ut_zalloc_nokey(sizeof(*recv_sys)));
}
mutex_enter(&(recv_sys->mutex)); mutex_create(LATCH_ID_RECV_SYS, &recv_sys->mutex);
mutex_create(LATCH_ID_RECV_WRITER, &recv_sys->writer_mutex);
recv_sys->heap = mem_heap_create_typed(256, recv_sys->heap = mem_heap_create_typed(256, MEM_HEAP_FOR_RECV_SYS);
MEM_HEAP_FOR_RECV_SYS);
if (!srv_read_only_mode) { if (!srv_read_only_mode) {
recv_sys->flush_start = os_event_create(0); recv_sys->flush_start = os_event_create(0);
recv_sys->flush_end = os_event_create(0); recv_sys->flush_end = os_event_create(0);
} }
ulint size = buf_pool_get_curr_size();
/* Set appropriate value of recv_n_pool_free_frames. */ /* Set appropriate value of recv_n_pool_free_frames. */
if (buf_pool_get_curr_size() >= (10 * 1024 * 1024)) { if (size >= 10 << 20) {
/* Buffer pool of size greater than 10 MB. */ /* Buffer pool of size greater than 10 MB. */
recv_n_pool_free_frames = 512; recv_n_pool_free_frames = 512;
} }
recv_sys->buf = static_cast<byte*>( recv_sys->buf = static_cast<byte*>(
ut_malloc_nokey(RECV_PARSING_BUF_SIZE)); ut_malloc_nokey(RECV_PARSING_BUF_SIZE));
recv_sys->len = 0;
recv_sys->recovered_offset = 0;
recv_sys->addr_hash = hash_create(available_memory / 512); recv_sys->addr_hash = hash_create(size / 512);
recv_sys->n_addrs = 0;
recv_sys->apply_log_recs = FALSE;
recv_sys->apply_batch_on = FALSE;
recv_sys->found_corrupt_log = false;
recv_sys->found_corrupt_fs = false;
recv_sys->mlog_checkpoint_lsn = 0;
recv_sys->progress_time = ut_time(); recv_sys->progress_time = ut_time();
recv_max_page_lsn = 0; recv_max_page_lsn = 0;
/* Call the constructor for recv_sys_t::dblwr member */ /* Call the constructor for recv_sys_t::dblwr member */
new (&recv_sys->dblwr) recv_dblwr_t(); new (&recv_sys->dblwr) recv_dblwr_t();
mutex_exit(&(recv_sys->mutex));
} }
/** Empty a fully processed hash table. */ /** Empty a fully processed hash table. */
......
...@@ -1831,8 +1831,7 @@ innobase_start_or_create_for_mysql() ...@@ -1831,8 +1831,7 @@ innobase_start_or_create_for_mysql()
fsp_init(); fsp_init();
log_sys_init(); log_sys_init();
recv_sys_create(); recv_sys_init();
recv_sys_init(buf_pool_get_curr_size());
lock_sys_create(srv_lock_table_size); lock_sys_create(srv_lock_table_size);
/* Create i/o-handler threads: */ /* Create i/o-handler threads: */
...@@ -2907,7 +2906,8 @@ innodb_shutdown() ...@@ -2907,7 +2906,8 @@ innodb_shutdown()
/* 4. Free all allocated memory */ /* 4. Free all allocated memory */
pars_lexer_close(); pars_lexer_close();
log_mem_free(); recv_sys_close();
ut_ad(buf_pool_ptr || !srv_was_started); ut_ad(buf_pool_ptr || !srv_was_started);
if (buf_pool_ptr) { if (buf_pool_ptr) {
buf_pool_free(srv_buf_pool_instances); buf_pool_free(srv_buf_pool_instances);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment