Commit 125b4bd6 authored by heikki@donna.mysql.fi's avatar heikki@donna.mysql.fi

log0log.c InnoDB now prints timestamp at startup and shutdown

srv0start.c	InnoDB now prints timestamp at startup and shutdown
ut0ut.h 	InnoDB now prints timestamp at startup and shutdown
ut0ut.c 	InnoDB now prints timestamp at startup and shutdown
parent 1993f268
...@@ -136,6 +136,13 @@ ut_difftime( ...@@ -136,6 +136,13 @@ ut_difftime(
/* out: time2 - time1 expressed in seconds */ /* out: time2 - time1 expressed in seconds */
ib_time_t time2, /* in: time */ ib_time_t time2, /* in: time */
ib_time_t time1); /* in: time */ ib_time_t time1); /* in: time */
/**************************************************************
Prints a timestamp to a file. */
void
ut_print_timestamp(
/*===============*/
FILE* file); /* in: file where to print */
/***************************************************************** /*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */ in microseconds on 100 MHz Pentium + Visual C++. */
......
...@@ -2634,8 +2634,9 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -2634,8 +2634,9 @@ logs_empty_and_mark_files_at_shutdown(void)
{ {
dulint lsn; dulint lsn;
ulint arch_log_no; ulint arch_log_no;
fprintf(stderr, "InnoDB: Starting shutdown...\n"); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Starting shutdown...\n");
/* Wait until the master thread and all other operations are idle: our /* Wait until the master thread and all other operations are idle: our
algorithm only works if the server is idle at shutdown */ algorithm only works if the server is idle at shutdown */
...@@ -2725,7 +2726,8 @@ loop: ...@@ -2725,7 +2726,8 @@ loop:
fil_flush_file_spaces(FIL_TABLESPACE); fil_flush_file_spaces(FIL_TABLESPACE);
fprintf(stderr, "InnoDB: Shutdown completed\n"); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Shutdown completed\n");
} }
/********************************************************** /**********************************************************
......
...@@ -813,7 +813,8 @@ innobase_start_or_create_for_mysql(void) ...@@ -813,7 +813,8 @@ innobase_start_or_create_for_mysql(void)
/* Create the thread which watches the timeouts for lock waits */ /* Create the thread which watches the timeouts for lock waits */
os_thread_create(&srv_lock_timeout_monitor_thread, NULL, os_thread_create(&srv_lock_timeout_monitor_thread, NULL,
thread_ids + 2 + SRV_MAX_N_IO_THREADS); thread_ids + 2 + SRV_MAX_N_IO_THREADS);
fprintf(stderr, "InnoDB: Started\n"); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Started\n");
srv_was_started = TRUE; srv_was_started = TRUE;
srv_is_being_started = FALSE; srv_is_being_started = FALSE;
...@@ -835,8 +836,9 @@ innobase_shutdown_for_mysql(void) ...@@ -835,8 +836,9 @@ innobase_shutdown_for_mysql(void)
{ {
if (!srv_was_started) { if (!srv_was_started) {
if (srv_is_being_started) { if (srv_is_being_started) {
ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: shutting down not properly started database\n"); " InnoDB: Warning: shutting down a not properly started database\n");
} }
return(DB_SUCCESS); return(DB_SUCCESS);
} }
......
...@@ -49,6 +49,43 @@ ut_difftime( ...@@ -49,6 +49,43 @@ ut_difftime(
return(difftime(time2, time1)); return(difftime(time2, time1));
} }
/**************************************************************
Prints a timestamp to a file. */
void
ut_print_timestamp(
/*===============*/
FILE* file) /* in: file where to print */
{
struct tm* cal_tm_ptr;
struct tm cal_tm;
time_t tm;
try_again:
time(&tm);
cal_tm_ptr = localtime(&tm);
memcpy(&cal_tm, cal_tm_ptr, sizeof(struct tm));
/* In theory localtime may return a wrong result because its return
struct is not protected with a mutex */
if (difftime(tm, mktime(&cal_tm)) > 0.5
|| difftime(tm, mktime(&cal_tm)) < -0.5) {
goto try_again;
}
fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
cal_tm.tm_year % 100,
cal_tm.tm_mon+1,
cal_tm.tm_mday,
cal_tm.tm_hour,
cal_tm.tm_min,
cal_tm.tm_sec);
}
/***************************************************************** /*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */ in microseconds on 100 MHz Pentium + Visual C++. */
......
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