diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 1a65c5f..6fa1748 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19735,7 +19735,7 @@ static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "Number of undo tablespaces to use. ", NULL, NULL, - 0L, /* Default seting */ + 8, /* Default seting */ 0L, /* Minimum value */ 95L, 0); /* Maximum value */ diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index 0dd98e5..c442a6e 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -147,6 +147,8 @@ extern bool srv_is_being_started; extern bool srv_sys_tablespaces_open; /** TRUE if the server was successfully started */ extern ibool srv_was_started; +/** True if it's a new databse that's been installed. */ +extern bool srv_is_being_created; /** TRUE if the server is being started, before rolling back any incomplete transactions */ extern bool srv_startup_is_before_trx_rollback_phase; diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 1e807f8..129350c 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -1052,7 +1052,9 @@ log_group_write_buf( ut_ad(!recv_no_log_write); ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0); - + /* If the server is not being installed, it should write from a lsn + that larger than LOG_START_LSN. */ + ut_a(srv_is_being_created || start_lsn != LOG_START_LSN); loop: if (len == 0) { diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 5e16c99..d257258 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -127,6 +127,9 @@ bool srv_startup_is_before_trx_rollback_phase = false; bool srv_is_being_started = false; /** TRUE if SYS_TABLESPACES is available for lookups */ bool srv_sys_tablespaces_open = false; +/** True if it's a new databse that's been installed. */ +bool srv_is_being_created = false; + /** TRUE if the server was successfully started */ ibool srv_was_started = FALSE; /** TRUE if innobase_start_or_create_for_mysql() has been called */ @@ -1040,12 +1043,20 @@ srv_undo_tablespaces_init( it != undo::Truncate::s_fix_up_spaces.end(); ++it) { + ut_a(log_sys->buf_next_to_write == 0); + ut_a(log_sys->lsn == LOG_START_LSN + LOG_BLOCK_HDR_SIZE); + ut_a(log_sys->buf_free == LOG_BLOCK_HDR_SIZE); + /* Modify buf_next_to_write so it won't try to write anything + to log file. */ + log_sys->buf_next_to_write = LOG_BLOCK_HDR_SIZE; + buf_LRU_flush_or_remove_pages( TRX_SYS_SPACE, BUF_REMOVE_FLUSH_WRITE, NULL); buf_LRU_flush_or_remove_pages( *it, BUF_REMOVE_FLUSH_WRITE, NULL); + log_sys->buf_next_to_write = 0; /* Remove the truncate redo log file. */ undo::Truncate undo_trunc; undo_trunc.done_logging(*it); @@ -1876,6 +1887,7 @@ innobase_start_or_create_for_mysql(void) } srv_startup_is_before_trx_rollback_phase = !create_new_db; + srv_is_being_created = create_new_db; /* Check if undo tablespaces and redo log files exist before creating a new system tablespace */ @@ -1893,6 +1905,8 @@ innobase_start_or_create_for_mysql(void) err = srv_sys_space.open_or_create( false, create_new_db, &sum_of_new_sizes, &flushed_lsn); + srv_is_being_created = create_new_db; + switch (err) { case DB_SUCCESS: break;