4304 Marko Mäkelä 2012-09-21
WL#6494: Replace redo logs when needed.
fil_close_log_files(): Close all redo log files.
Forked from fil_close_all_files().
innobase_start_or_create_for_mysql(): Replace the redo log files
if their current size or amount differs from the configuration.
modified:
storage/innobase/fil/fil0fil.cc
storage/innobase/include/fil0fil.h
storage/innobase/srv/srv0start.cc
4303 Marko Mäkelä 2012-09-20
Fix errors in the previous commit, refactoring of open_or_create_log_file().
modified:
storage/innobase/srv/srv0start.cc
=== modified file 'storage/innobase/fil/fil0fil.cc'
--- a/storage/innobase/fil/fil0fil.cc revid:marko.makela@oracle.com-20120920192156-rkqr5aa42zbrydwz
+++ b/storage/innobase/fil/fil0fil.cc revid:marko.makela@stripped120921064458-vznpyafuvhb6w81t
@@ -1762,6 +1762,46 @@ fil_close_all_files(void)
}
/*******************************************************************//**
+Closes the redo log files. There must not be any pending i/o's or not
+flushed modifications in the files. */
+UNIV_INTERN
+void
+fil_close_log_files(void)
+/*=====================*/
+{
+ fil_space_t* space;
+
+ mutex_enter(&fil_system->mutex);
+
+ space = UT_LIST_GET_FIRST(fil_system->space_list);
+
+ while (space != NULL) {
+ fil_node_t* node;
+ fil_space_t* prev_space = space;
+
+ if (space->purpose != FIL_LOG) {
+ space = UT_LIST_GET_NEXT(space_list, space);
+ continue;
+ }
+
+ for (node = UT_LIST_GET_FIRST(space->chain);
+ node != NULL;
+ node = UT_LIST_GET_NEXT(chain, node)) {
+
+ if (node->open) {
+ fil_node_close_file(node, fil_system);
+ }
+ }
+
+ space = UT_LIST_GET_NEXT(space_list, space);
+
+ fil_space_free(prev_space->id, FALSE);
+ }
+
+ mutex_exit(&fil_system->mutex);
+}
+
+/*******************************************************************//**
Sets the max tablespace id counter if the given number is bigger than the
previous value. */
UNIV_INTERN
=== modified file 'storage/innobase/include/fil0fil.h'
--- a/storage/innobase/include/fil0fil.h revid:marko.makela@stripped-rkqr5aa42zbrydwz
+++ b/storage/innobase/include/fil0fil.h revid:marko.makela@strippedb6w81t
@@ -325,6 +325,13 @@ void
fil_close_all_files(void);
/*=====================*/
/*******************************************************************//**
+Closes the redo log files. There must not be any pending i/o's or not
+flushed modifications in the files. */
+UNIV_INTERN
+void
+fil_close_log_files(void);
+/*=====================*/
+/*******************************************************************//**
Sets the max tablespace id counter if the given number is bigger than the
previous value. */
UNIV_INTERN
=== modified file 'storage/innobase/srv/srv0start.cc'
--- a/storage/innobase/srv/srv0start.cc revid:marko.makela@strippedz
+++ b/storage/innobase/srv/srv0start.cc revid:marko.makela@stripped
@@ -2111,11 +2111,6 @@ create_log_files:
return(DB_ERROR);
}
- if (i != srv_n_log_files
- || srv_log_file_size_requested != srv_log_file_size) {
- ut_error; /* TODO */
- }
-
/* Since the insert buffer init is in dict_boot, and the
insert buffer is needed in any disk i/o, first we call
dict_boot(). Note that trx_sys_init_at_db_start() only needs
@@ -2157,6 +2152,129 @@ create_log_files:
recv_needed_recovery);
}
+ if (!srv_force_recovery
+ && !recv_sys->found_corrupt_log
+ && (srv_log_file_size_requested != srv_log_file_size
+ || i != srv_n_log_files)) {
+ /* Prepare to replace the redo log files. */
+
+ /* Clean the buffer pool. */
+ bool success = buf_flush_list(
+ ULINT_MAX, LSN_MAX, NULL);
+ ut_a(success);
+
+ min_flushed_lsn = max_flushed_lsn = log_get_lsn();
+
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Resizing redo log from %u*%u to %u*%u pages"
+ ", LSN=" LSN_PF,
+ (unsigned) i,
+ (unsigned) srv_log_file_size,
+ (unsigned) srv_n_log_files,
+ (unsigned) srv_log_file_size_requested,
+ max_flushed_lsn);
+
+ buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
+
+ /* Flush the old log files. */
+ log_buffer_flush_to_disk();
+
+ ut_ad(max_flushed_lsn == log_get_lsn());
+
+ ut_d(recv_no_log_write = TRUE);
+ ut_ad(!buf_pool_check_no_pending_io());
+
+ /* Stamp the LSN to the data files. */
+ fil_write_flushed_lsn_to_data_files(
+ max_flushed_lsn, 0);
+
+ fil_flush_file_spaces(FIL_TABLESPACE);
+
+ /* Close the redo log files, so that we can
+ replace them. */
+ fil_close_log_files();
+
+ /* Free the old log file space. */
+ log_group_close_all();
+
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "Starting to delete and rewrite log files.");
+
+ /* Remove the old log files. */
+ for (ulint j = 0; j < i; j++) {
+ os_file_stat_t stat_info;
+
+ sprintf(logfilename + dirnamelen,
+ "ib_logfile%lu", (ulong) j);
+
+ err = os_file_get_status(
+ logfilename, &stat_info, false);
+
+ if (err == DB_NOT_FOUND) {
+ break;
+ }
+
+ if (!os_file_delete(logfilename)) {
+ return(DB_ERROR);
+ }
+ }
+
+ ut_ad(!buf_pool_check_no_pending_io());
+
+ srv_log_file_size = srv_log_file_size_requested;
+
+ /* Create new log files. */
+ for (i = 0; i < srv_n_log_files; i++) {
+ sprintf(logfilename + dirnamelen,
+ "ib_logfile%lu", (ulong) i);
+
+ err = create_log_file(&files[i], logfilename);
+
+ if (err != DB_SUCCESS) {
+ return(err);
+ }
+ }
+
+ log_created = TRUE;
+
+ sprintf(logfilename + dirnamelen,
+ "ib_logfile%lu", 0UL);
+
+ fil_space_create(
+ logfilename, SRV_LOG_SPACE_FIRST_ID,
+ fsp_flags_set_page_size(0, UNIV_PAGE_SIZE),
+ FIL_LOG);
+ ut_a(fil_validate());
+
+ for (i = 0; i < srv_n_log_files; i++) {
+ sprintf(logfilename + dirnamelen,
+ "ib_logfile%lu", (ulong) i);
+
+ fil_node_create(
+ logfilename, (ulint) srv_log_file_size,
+ SRV_LOG_SPACE_FIRST_ID, FALSE);
+ }
+
+ log_group_init(0, srv_n_log_files,
+ srv_log_file_size * UNIV_PAGE_SIZE,
+ SRV_LOG_SPACE_FIRST_ID,
+ SRV_LOG_SPACE_FIRST_ID + 1);
+
+ fil_open_log_and_system_tablespace_files();
+
+ /* Create a log checkpoint. */
+ mutex_enter(&log_sys->mutex);
+ ut_d(recv_no_log_write = FALSE);
+ ut_ad(max_flushed_lsn == log_sys->lsn);
+ recv_reset_logs(max_flushed_lsn, TRUE);
+ mutex_exit(&log_sys->mutex);
+
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "New log files created"
+ ", LSN=" LSN_PF,
+ max_flushed_lsn);
+ }
+
srv_startup_is_before_trx_rollback_phase = FALSE;
recv_recovery_rollback_active();
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-5.6-wl6494 branch (marko.makela:4303 to 4304) WL#6494 | marko.makela | 21 Sep |