Commit fc4364e3 authored by unknown's avatar unknown

InnoDB: Add option for disabling innodb_status.<pid> files.

InnoDB: Implement tmpfile() differently on Windows (Bug #3998)


innobase/dict/dict0dict.c:
  Check the return value of os_file_create_tmpfile(),
  as it can now return NULL
innobase/include/os0file.h:
  Note that os_file_create_tmpfile() can now return NULL
innobase/include/srv0srv.h:
  Add a new server flag (srv_innodb_status) to disable
  the creation of innodb_status.<pid> files
innobase/lock/lock0lock.c:
  Check the return value of os_file_create_tmpfile(),
  as it can now return NULL
innobase/os/os0file.c:
  os_file_create_tmpfile(): separate implementation for Win32;
  errors will be reported but will not cause assertion failure
innobase/srv/srv0srv.c:
  Add a new server flag (srv_innodb_status) to disable
  the creation of innodb_status.<pid> files
innobase/srv/srv0start.c:
  innobase_start_or_create_for_mysql(): create srv_monitor_file
  with tmpfile() or with a visible name "innodb_status.<pid>",
  depending on the setting of the flag srv_innodb_status.
sql/ha_innodb.cc:
  innobase_init(): initialize srv_innodb_status
  update_table_comment(), get_foreign_key_create_info(): replace
  tmpfile() with os_file_create_tmpfile()
sql/ha_innodb.h:
  Add new Boolean flag, innobase_create_status_file.
sql/mysqld.cc:
  Add new Boolean flag, innodb_status_file
parent 06cd2efc
...@@ -643,6 +643,7 @@ dict_init(void) ...@@ -643,6 +643,7 @@ dict_init(void)
rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION); rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
dict_foreign_err_file = os_file_create_tmpfile(); dict_foreign_err_file = os_file_create_tmpfile();
ut_a(dict_foreign_err_file);
mutex_create(&dict_foreign_err_mutex); mutex_create(&dict_foreign_err_mutex);
mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH); mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
} }
......
...@@ -139,7 +139,7 @@ Creates a temporary file. In case of error, causes abnormal termination. */ ...@@ -139,7 +139,7 @@ Creates a temporary file. In case of error, causes abnormal termination. */
FILE* FILE*
os_file_create_tmpfile(void); os_file_create_tmpfile(void);
/*========================*/ /*========================*/
/* out: temporary file handle (never NULL) */ /* out: temporary file handle, or NULL */
/******************************************************************** /********************************************************************
A simple function to open or create a file. */ A simple function to open or create a file. */
......
...@@ -92,6 +92,8 @@ extern lint srv_conc_n_threads; ...@@ -92,6 +92,8 @@ extern lint srv_conc_n_threads;
extern ibool srv_fast_shutdown; extern ibool srv_fast_shutdown;
extern ibool srv_innodb_status;
extern ibool srv_use_doublewrite_buf; extern ibool srv_use_doublewrite_buf;
extern ibool srv_set_thread_priorities; extern ibool srv_set_thread_priorities;
......
...@@ -509,6 +509,7 @@ lock_sys_create( ...@@ -509,6 +509,7 @@ lock_sys_create(
/* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */ /* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */
lock_latest_err_file = os_file_create_tmpfile(); lock_latest_err_file = os_file_create_tmpfile();
ut_a(lock_latest_err_file);
} }
/************************************************************************* /*************************************************************************
......
...@@ -377,16 +377,33 @@ Creates a temporary file. In case of error, causes abnormal termination. */ ...@@ -377,16 +377,33 @@ Creates a temporary file. In case of error, causes abnormal termination. */
FILE* FILE*
os_file_create_tmpfile(void) os_file_create_tmpfile(void)
/*========================*/ /*========================*/
/* out: temporary file handle (never NULL) */ /* out: temporary file handle, or NULL */
{ {
FILE* file = tmpfile(); FILE* file;
#ifdef __WIN__
int fd = -1;
char* name;
file = NULL;
if (NULL == (name = tempnam(fil_path_to_mysql_datadir, "ib"))
|| -1 == (fd = _open(name, _O_CREAT | _O_EXCL | _O_RDWR
| _O_SEQUENTIAL | _O_SHORT_LIVED | _O_TEMPORARY))
|| NULL == (file = fdopen(fd, "w+b"))) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: unable to create"
" temporary file %s\n", name ? name : "name");
if (fd != -1) {
_close(fd);
}
}
free(name);
#else /* __WIN__ */
file = tmpfile();
if (file == NULL) { if (file == NULL) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(" InnoDB: Error: unable to create temporary file\n", fputs(" InnoDB: Error: unable to create temporary file\n",
stderr); stderr);
os_file_handle_error(NULL, "tmpfile");
ut_error;
} }
#endif /* __WIN__ */
return(file); return(file);
} }
......
...@@ -223,6 +223,9 @@ merge to completion before shutdown */ ...@@ -223,6 +223,9 @@ merge to completion before shutdown */
ibool srv_fast_shutdown = FALSE; ibool srv_fast_shutdown = FALSE;
/* Generate a innodb_status.<pid> file */
ibool srv_innodb_status = FALSE;
ibool srv_use_doublewrite_buf = TRUE; ibool srv_use_doublewrite_buf = TRUE;
ibool srv_set_thread_priorities = TRUE; ibool srv_set_thread_priorities = TRUE;
......
...@@ -1023,16 +1023,24 @@ NetWare. */ ...@@ -1023,16 +1023,24 @@ NetWare. */
mutex_create(&srv_monitor_file_mutex); mutex_create(&srv_monitor_file_mutex);
mutex_set_level(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK); mutex_set_level(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
srv_monitor_file_name = mem_alloc( if (srv_innodb_status) {
strlen(fil_path_to_mysql_datadir) + srv_monitor_file_name = mem_alloc(
20 + sizeof "/innodb_status."); strlen(fil_path_to_mysql_datadir) +
sprintf(srv_monitor_file_name, "%s/innodb_status.%lu", 20 + sizeof "/innodb_status.");
fil_path_to_mysql_datadir, os_proc_get_number()); sprintf(srv_monitor_file_name, "%s/innodb_status.%lu",
srv_monitor_file = fopen(srv_monitor_file_name, "w+"); fil_path_to_mysql_datadir, os_proc_get_number());
if (!srv_monitor_file) { srv_monitor_file = fopen(srv_monitor_file_name, "w+");
fprintf(stderr, "InnoDB: unable to create %s: %s\n", if (!srv_monitor_file) {
srv_monitor_file_name, strerror(errno)); fprintf(stderr, "InnoDB: unable to create %s: %s\n",
return(DB_ERROR); srv_monitor_file_name, strerror(errno));
return(DB_ERROR);
}
} else {
srv_monitor_file_name = NULL;
srv_monitor_file = os_file_create_tmpfile();
if (!srv_monitor_file) {
return(DB_ERROR);
}
} }
/* Restrict the maximum number of file i/o threads */ /* Restrict the maximum number of file i/o threads */
...@@ -1527,8 +1535,10 @@ innobase_shutdown_for_mysql(void) ...@@ -1527,8 +1535,10 @@ innobase_shutdown_for_mysql(void)
if (srv_monitor_file) { if (srv_monitor_file) {
fclose(srv_monitor_file); fclose(srv_monitor_file);
srv_monitor_file = 0; srv_monitor_file = 0;
unlink(srv_monitor_file_name); if (srv_monitor_file_name) {
mem_free(srv_monitor_file_name); unlink(srv_monitor_file_name);
mem_free(srv_monitor_file_name);
}
} }
mutex_free(&srv_monitor_file_mutex); mutex_free(&srv_monitor_file_mutex);
......
...@@ -103,6 +103,7 @@ uint innobase_flush_log_at_trx_commit = 1; ...@@ -103,6 +103,7 @@ uint innobase_flush_log_at_trx_commit = 1;
my_bool innobase_log_archive = FALSE; my_bool innobase_log_archive = FALSE;
my_bool innobase_use_native_aio = FALSE; my_bool innobase_use_native_aio = FALSE;
my_bool innobase_fast_shutdown = TRUE; my_bool innobase_fast_shutdown = TRUE;
my_bool innobase_create_status_file = FALSE;
static char *internal_innobase_data_file_path = NULL; static char *internal_innobase_data_file_path = NULL;
...@@ -861,6 +862,7 @@ innobase_init(void) ...@@ -861,6 +862,7 @@ innobase_init(void)
srv_force_recovery = (ulint) innobase_force_recovery; srv_force_recovery = (ulint) innobase_force_recovery;
srv_fast_shutdown = (ibool) innobase_fast_shutdown; srv_fast_shutdown = (ibool) innobase_fast_shutdown;
srv_innodb_status = (ibool) innobase_create_status_file;
srv_print_verbose_log = mysql_embedded ? 0 : 1; srv_print_verbose_log = mysql_embedded ? 0 : 1;
...@@ -4270,7 +4272,7 @@ ha_innobase::update_table_comment( ...@@ -4270,7 +4272,7 @@ ha_innobase::update_table_comment(
trx_search_latch_release_if_reserved(prebuilt->trx); trx_search_latch_release_if_reserved(prebuilt->trx);
str = NULL; str = NULL;
if (FILE* file = tmpfile()) { if (FILE* file = os_file_create_tmpfile()) {
long flen; long flen;
/* output the data to a temporary file */ /* output the data to a temporary file */
...@@ -4330,7 +4332,7 @@ ha_innobase::get_foreign_key_create_info(void) ...@@ -4330,7 +4332,7 @@ ha_innobase::get_foreign_key_create_info(void)
update_thd(current_thd); update_thd(current_thd);
if (FILE* file = tmpfile()) { if (FILE* file = os_file_create_tmpfile()) {
long flen; long flen;
prebuilt->trx->op_info = (char*)"getting info on foreign keys"; prebuilt->trx->op_info = (char*)"getting info on foreign keys";
......
...@@ -203,7 +203,8 @@ extern char *innobase_log_group_home_dir, *innobase_log_arch_dir; ...@@ -203,7 +203,8 @@ extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
extern char *innobase_unix_file_flush_method; extern char *innobase_unix_file_flush_method;
/* The following variables have to be my_bool for SHOW VARIABLES to work */ /* The following variables have to be my_bool for SHOW VARIABLES to work */
extern my_bool innobase_log_archive, extern my_bool innobase_log_archive,
innobase_use_native_aio, innobase_fast_shutdown; innobase_use_native_aio, innobase_fast_shutdown,
innobase_create_status_file;
extern "C" { extern "C" {
extern ulong srv_max_buf_pool_modified_pct; extern ulong srv_max_buf_pool_modified_pct;
} }
......
...@@ -3458,6 +3458,7 @@ enum options_mysqld { ...@@ -3458,6 +3458,7 @@ enum options_mysqld {
OPT_INNODB_LOCK_WAIT_TIMEOUT, OPT_INNODB_LOCK_WAIT_TIMEOUT,
OPT_INNODB_THREAD_CONCURRENCY, OPT_INNODB_THREAD_CONCURRENCY,
OPT_INNODB_FORCE_RECOVERY, OPT_INNODB_FORCE_RECOVERY,
OPT_INNODB_STATUS_FILE,
OPT_INNODB_MAX_DIRTY_PAGES_PCT, OPT_INNODB_MAX_DIRTY_PAGES_PCT,
OPT_BDB_CACHE_SIZE, OPT_BDB_CACHE_SIZE,
OPT_BDB_LOG_BUFFER_SIZE, OPT_BDB_LOG_BUFFER_SIZE,
...@@ -3625,6 +3626,10 @@ struct my_option my_long_options[] = ...@@ -3625,6 +3626,10 @@ struct my_option my_long_options[] =
{"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN, {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
"Speeds up server shutdown process", (gptr*) &innobase_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}, (gptr*) &innobase_fast_shutdown, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
{"innodb_status_file", OPT_INNODB_STATUS_FILE,
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
(gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file,
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT,
"Percentage of dirty pages allowed in bufferpool", (gptr*) &srv_max_buf_pool_modified_pct, "Percentage of dirty pages allowed in bufferpool", (gptr*) &srv_max_buf_pool_modified_pct,
(gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, (gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0},
......
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