Commit 43b1125c authored by unknown's avatar unknown

Adding --innodb_fast_shutdown=2 which shuts down InnoDB faster than the default "1":

most InnoDB threads are not terminated properly and the buffer pool is not flushed
to disk. Still no committed transaction is lost as we flush the logs to disk.
InnoDB does crash recovery at startup after this shutdown.
Using this shutdown in testsuite (mysql-test-run --mysqld=--innodb_fast_shutdown=2) saved 3 minutes (13% of total time).


innobase/include/srv0srv.h:
  srv_fast_shutdown now int to allow 3 values, replacing the srv_fast_shutdown/srv_very_fast_shutdown combo
innobase/log/log0log.c:
  srv_very_fast_shutdown -> (srv_fast_shutdown == 2)
innobase/srv/srv0srv.c:
  srv_very_fast_shutdown -> (srv_fast_shutdown == 2)
innobase/srv/srv0start.c:
  moving message to the InnoDB internal code (like "InnoDB: Starting shutdown" is)
  instead of ha_innodb.cc. That's to have ut_print_timestamp().
sql/ha_innodb.cc:
  As innodb_fast_shutdown is now settable, srv_fast_shutdown must be
  set at shutdown, not at startup.
sql/ha_innodb.h:
  innobase_fast_shutdown now ulong to accept 3 values
sql/mysqld.cc:
  Making the "very fast" InnoDB shutdown accessible to users, by passing
  --innodb-fast-shutdown=2 (disabled on Netware)
sql/set_var.cc:
  innodb_fast_shutdown now settable on the fly (global variable).
  So that user can decide to do a normal/fast/fastest shutdown
  just before doing it.
parent e35244d6
......@@ -99,11 +99,13 @@ extern ulint srv_max_n_threads;
extern lint srv_conc_n_threads;
extern ibool srv_fast_shutdown;
extern ibool srv_very_fast_shutdown; /* if this TRUE, do not flush the
extern ulint srv_fast_shutdown; /* If this is 1, do not do a
purge and index buffer merge.
If this 2, do not even flush the
buffer pool to data files at the
shutdown; we effectively 'crash'
InnoDB */
shutdown: we effectively 'crash'
InnoDB (but lose no committed
transactions). */
extern ibool srv_innodb_status;
extern ibool srv_use_doublewrite_buf;
......
......@@ -3059,15 +3059,13 @@ loop:
goto loop;
}
if (srv_very_fast_shutdown) {
/* In a 'very fast' shutdown we do not flush the buffer pool:
if (srv_fast_shutdown == 2) {
/* In this fastest shutdown we do not flush the buffer pool:
it is essentially a 'crash' of the InnoDB server.
Make sure that the log is all flushed to disk, so that
we can recover all committed transactions in a crash
recovery.
In a 'very fast' shutdown we do not flush the buffer pool:
it is essentially a 'crash' of the InnoDB server. Then we must
not write the lsn stamps to the data files, since at a
We must not write the lsn stamps to the data files, since at a
startup InnoDB deduces from the stamps if the previous
shutdown was clean. */
......
......@@ -300,15 +300,12 @@ SQL query after it has once got the ticket at srv_conc_enter_innodb */
#define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter
#define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay
/*-----------------------*/
/* If the following is set TRUE then we do not run purge and insert buffer
merge to completion before shutdown */
/* If the following is set to 1 then we do not run purge and insert buffer
merge to completion before shutdown. If it is set to 2, do not even flush the
buffer pool to data files at the shutdown: we effectively 'crash'
InnoDB (but lose no committed transactions). */
ulint srv_fast_shutdown = 0;
ibool srv_fast_shutdown = FALSE;
ibool srv_very_fast_shutdown = FALSE; /* if this TRUE, do not flush the
buffer pool to data files at the
shutdown; we effectively 'crash'
InnoDB */
/* Generate a innodb_status.<pid> file */
ibool srv_innodb_status = FALSE;
......@@ -2471,11 +2468,11 @@ background_loop:
flush_loop:
srv_main_thread_op_info = "flushing buffer pool pages";
if (!srv_very_fast_shutdown) {
if (srv_fast_shutdown < 2) {
n_pages_flushed =
buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
} else {
/* In a 'very fast' shutdown we do not flush the buffer pool
/* In the fastest shutdown we do not flush the buffer pool
to data files: we set n_pages_flushed to 0 artificially. */
n_pages_flushed = 0;
......
......@@ -1729,6 +1729,15 @@ innobase_shutdown_for_mysql(void)
The step 1 is the real InnoDB shutdown. The remaining steps 2 - ...
just free data structures after the shutdown. */
if (srv_fast_shutdown == 2) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: MySQL has requested a very fast shutdown without flushing "
"the InnoDB buffer pool to data files. At the next mysqld startup "
"InnoDB will do a crash recovery!\n");
}
#ifdef __NETWARE__
if(!panic_shutdown)
#endif
......
......@@ -116,15 +116,12 @@ char* innobase_unix_file_flush_method = NULL;
values */
uint innobase_flush_log_at_trx_commit = 1;
ulong innobase_fast_shutdown = 1;
my_bool innobase_log_archive = FALSE;/* unused */
my_bool innobase_use_doublewrite = TRUE;
my_bool innobase_use_checksums = TRUE;
my_bool innobase_use_large_pages = FALSE;
my_bool innobase_use_native_aio = FALSE;
my_bool innobase_fast_shutdown = TRUE;
my_bool innobase_very_fast_shutdown = FALSE; /* this can be set to
1 just prior calling
innobase_end() */
my_bool innobase_file_per_table = FALSE;
my_bool innobase_locks_unsafe_for_binlog = FALSE;
my_bool innobase_create_status_file = FALSE;
......@@ -1238,8 +1235,6 @@ innobase_init(void)
srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
srv_force_recovery = (ulint) innobase_force_recovery;
srv_fast_shutdown = (ibool) innobase_fast_shutdown;
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
srv_use_checksums = (ibool) innobase_use_checksums;
......@@ -1330,17 +1325,7 @@ innobase_end(void)
#endif
if (innodb_inited) {
#ifndef __NETWARE__ /* NetWare can't close unclosed files, kill remaining
threads, etc, so we disable the very fast shutdown */
if (innobase_very_fast_shutdown) {
srv_very_fast_shutdown = TRUE;
fprintf(stderr,
"InnoDB: MySQL has requested a very fast shutdown without flushing\n"
"InnoDB: the InnoDB buffer pool to data files. At the next mysqld startup\n"
"InnoDB: InnoDB will do a crash recovery!\n");
}
#endif
srv_fast_shutdown = (ulint) innobase_fast_shutdown;
innodb_inited = 0;
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
err = 1;
......
......@@ -210,7 +210,7 @@ class ha_innobase: public handler
extern struct show_var_st innodb_status_variables[];
extern uint innobase_init_flags, innobase_lock_type;
extern uint innobase_flush_log_at_trx_commit;
extern ulong innobase_cache_size;
extern ulong innobase_cache_size, innobase_fast_shutdown;
extern ulong innobase_large_page_size;
extern char *innobase_home, *innobase_tmpdir, *innobase_logdir;
extern long innobase_lock_scan_time;
......@@ -229,7 +229,7 @@ extern my_bool innobase_log_archive,
innobase_use_doublewrite,
innobase_use_checksums,
innobase_use_large_pages,
innobase_use_native_aio, innobase_fast_shutdown,
innobase_use_native_aio,
innobase_file_per_table, innobase_locks_unsafe_for_binlog,
innobase_create_status_file;
extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before
......
......@@ -4494,8 +4494,24 @@ Disable with --skip-innodb-checksums.", (gptr*) &innobase_use_checksums,
Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
(gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
"Speeds up server shutdown process.", (gptr*) &innobase_fast_shutdown,
(gptr*) &innobase_fast_shutdown, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
"values are 0, 1 (faster)"
/*
NetWare can't close unclosed files, can't automatically kill remaining
threads, etc, so on this OS we disable the crash-like InnoDB shutdown.
*/
#ifndef __NETWARE__
" or 2 (fastest - crash-like)"
#endif
".",
(gptr*) &innobase_fast_shutdown,
(gptr*) &innobase_fast_shutdown, 0, GET_ULONG, OPT_ARG, 1, 0,
#ifndef __NETWARE__
2,
#else
1,
#endif
0, 0, 0},
{"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE,
"Stores each InnoDB table to an .ibd file in the database dir.",
(gptr*) &innobase_file_per_table,
......@@ -6510,9 +6526,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_INNODB_LOG_ARCHIVE:
innobase_log_archive= argument ? test(atoi(argument)) : 1;
break;
case OPT_INNODB_FAST_SHUTDOWN:
innobase_fast_shutdown= argument ? test(atoi(argument)) : 1;
break;
#endif /* HAVE_INNOBASE_DB */
case OPT_MYISAM_RECOVER:
{
......
......@@ -386,6 +386,8 @@ sys_var_thd_ulong sys_net_wait_timeout("wait_timeout",
&SV::net_wait_timeout);
#ifdef HAVE_INNOBASE_DB
sys_var_long_ptr sys_innodb_fast_shutdown("innodb_fast_shutdown",
&innobase_fast_shutdown);
sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct",
&srv_max_buf_pool_modified_pct);
sys_var_long_ptr sys_innodb_max_purge_lag("innodb_max_purge_lag",
......@@ -689,6 +691,7 @@ sys_var *sys_variables[]=
&sys_tx_isolation,
&sys_os,
#ifdef HAVE_INNOBASE_DB
&sys_innodb_fast_shutdown,
&sys_innodb_max_dirty_pages_pct,
&sys_innodb_max_purge_lag,
&sys_innodb_table_locks,
......@@ -795,7 +798,7 @@ struct show_var_st init_vars[]= {
{"innodb_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR},
{"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
{"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL},
{"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL},
{sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
{"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
{"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_INT},
......
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