summaryrefslogtreecommitdiff
path: root/innobase/srv
diff options
context:
space:
mode:
authorheikki@donna.mysql.fi <>2001-08-04 19:36:14 +0300
committerheikki@donna.mysql.fi <>2001-08-04 19:36:14 +0300
commit94db78ce61a998d28a9335bade3e5e1df558a4ea (patch)
treee6dc89cb458f496f2b93e907afb60d3cd886cc18 /innobase/srv
parent596d69b5ce815c325d8a1af7934ed50efce5aed3 (diff)
downloadmariadb-git-94db78ce61a998d28a9335bade3e5e1df558a4ea.tar.gz
srv0srv.h Support raw disk partitions as data files
srv0start.c Support raw disk partitions as data files srv0srv.c Support raw disk partitions as data files row0purge.c < 4 GB rows, doublewrite, hang fixes row0row.c < 4 GB rows, doublewrite, hang fixes row0sel.c < 4 GB rows, doublewrite, hang fixes row0uins.c < 4 GB rows, doublewrite, hang fixes row0umod.c < 4 GB rows, doublewrite, hang fixes row0undo.c < 4 GB rows, doublewrite, hang fixes row0upd.c < 4 GB rows, doublewrite, hang fixes srv0srv.c < 4 GB rows, doublewrite, hang fixes srv0start.c < 4 GB rows, doublewrite, hang fixes sync0rw.c < 4 GB rows, doublewrite, hang fixes sync0sync.c < 4 GB rows, doublewrite, hang fixes trx0purge.c < 4 GB rows, doublewrite, hang fixes trx0rec.c < 4 GB rows, doublewrite, hang fixes trx0sys.c < 4 GB rows, doublewrite, hang fixes btr0btr.c < 4 GB rows, doublewrite, hang fixes btr0cur.c < 4 GB rows, doublewrite, hang fixes buf0buf.c < 4 GB rows, doublewrite, hang fixes buf0flu.c < 4 GB rows, doublewrite, hang fixes buf0rea.c < 4 GB rows, doublewrite, hang fixes data0data.c < 4 GB rows, doublewrite, hang fixes fil0fil.c < 4 GB rows, doublewrite, hang fixes fsp0fsp.c < 4 GB rows, doublewrite, hang fixes ibuf0ibuf.c < 4 GB rows, doublewrite, hang fixes lock0lock.c < 4 GB rows, doublewrite, hang fixes log0log.c < 4 GB rows, doublewrite, hang fixes log0recv.c < 4 GB rows, doublewrite, hang fixes os0file.c < 4 GB rows, doublewrite, hang fixes page0cur.c < 4 GB rows, doublewrite, hang fixes pars0pars.c < 4 GB rows, doublewrite, hang fixes rem0cmp.c < 4 GB rows, doublewrite, hang fixes rem0rec.c < 4 GB rows, doublewrite, hang fixes row0ins.c < 4 GB rows, doublewrite, hang fixes row0mysql.c < 4 GB rows, doublewrite, hang fixes univ.i < 4 GB rows, doublewrite, hang fixes data0data.ic < 4 GB rows, doublewrite, hang fixes mach0data.ic < 4 GB rows, doublewrite, hang fixes rem0rec.ic < 4 GB rows, doublewrite, hang fixes row0upd.ic < 4 GB rows, doublewrite, hang fixes trx0rec.ic < 4 GB rows, doublewrite, hang fixes rem0cmp.h < 4 GB rows, doublewrite, hang fixes rem0rec.h < 4 GB rows, doublewrite, hang fixes row0ins.h < 4 GB rows, doublewrite, hang fixes row0mysql.h < 4 GB rows, doublewrite, hang fixes row0row.h < 4 GB rows, doublewrite, hang fixes row0upd.h < 4 GB rows, doublewrite, hang fixes srv0srv.h < 4 GB rows, doublewrite, hang fixes sync0sync.h < 4 GB rows, doublewrite, hang fixes trx0rec.h < 4 GB rows, doublewrite, hang fixes trx0sys.h < 4 GB rows, doublewrite, hang fixes trx0types.h < 4 GB rows, doublewrite, hang fixes trx0undo.h < 4 GB rows, doublewrite, hang fixes ut0dbg.h < 4 GB rows, doublewrite, hang fixes ut0ut.h < 4 GB rows, doublewrite, hang fixes btr0btr.h < 4 GB rows, doublewrite, hang fixes btr0cur.h < 4 GB rows, doublewrite, hang fixes buf0buf.h < 4 GB rows, doublewrite, hang fixes buf0flu.h < 4 GB rows, doublewrite, hang fixes data0data.h < 4 GB rows, doublewrite, hang fixes dict0mem.h < 4 GB rows, doublewrite, hang fixes fil0fil.h < 4 GB rows, doublewrite, hang fixes fsp0fsp.h < 4 GB rows, doublewrite, hang fixes os0file.h < 4 GB rows, doublewrite, hang fixes
Diffstat (limited to 'innobase/srv')
-rw-r--r--innobase/srv/srv0srv.c160
-rw-r--r--innobase/srv/srv0start.c133
2 files changed, 153 insertions, 140 deletions
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 028fae010d5..8dd9c9f3feb 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -93,6 +93,8 @@ ulint srv_lock_wait_timeout = 1024 * 1024 * 1024;
char* srv_unix_file_flush_method_str = NULL;
ulint srv_unix_file_flush_method = 0;
+ibool srv_use_doublewrite_buf = TRUE;
+
ibool srv_set_thread_priorities = TRUE;
int srv_query_thread_priority = 0;
/*-------------------------------------------*/
@@ -109,6 +111,8 @@ ibool srv_print_buf_io = FALSE;
ibool srv_print_log_io = FALSE;
ibool srv_print_latch_waits = FALSE;
+ibool srv_print_innodb_monitor = FALSE;
+
/* The parameters below are obsolete: */
ibool srv_print_parsed_sql = FALSE;
@@ -1492,7 +1496,6 @@ srv_init(void)
slot = srv_mysql_table + i;
slot->in_use = FALSE;
slot->event = os_event_create(NULL);
- slot->suspended = FALSE;
ut_a(slot->event);
}
@@ -1661,7 +1664,6 @@ srv_suspend_mysql_thread(
slot->thr = thr;
os_event_reset(event);
- slot->suspended = TRUE;
slot->suspend_time = ut_time();
@@ -1693,27 +1695,6 @@ srv_suspend_mysql_thread(
return(FALSE);
}
-os_event_t
-srv_mysql_thread_event_get(void)
-{
- srv_slot_t* slot;
- os_event_t event;
-
- mutex_enter(&kernel_mutex);
-
- slot = srv_table_reserve_slot_for_mysql();
-
- event = slot->event;
-
- os_event_reset(event);
-
- slot->suspended = TRUE;
-
- mutex_exit(&kernel_mutex);
-
- return(event);
-}
-
/************************************************************************
Releases a MySQL OS thread waiting for a lock to be released, if the
thread is already suspended. */
@@ -1737,7 +1718,6 @@ srv_release_mysql_thread_if_suspended(
/* Found */
os_event_set(slot->event);
- slot->suspended = FALSE;
return;
}
@@ -1746,59 +1726,6 @@ srv_release_mysql_thread_if_suspended(
/* not found */
}
-void
-srv_mysql_thread_release(void)
-/*==========================*/
-{
- srv_slot_t* slot;
- ulint i;
-
- mutex_enter(&kernel_mutex);
-
- for (i = 0; i < OS_THREAD_MAX_N; i++) {
-
- slot = srv_mysql_table + i;
-
- if (slot->in_use && slot->suspended) {
- /* Found */
- slot->suspended = FALSE;
- mutex_exit(&kernel_mutex);
-
- os_event_set(slot->event);
-
- return;
- }
- }
-
- ut_a(0);
-}
-
-void
-srv_mysql_thread_slot_free(
-/*==========================*/
- os_event_t event)
-{
- srv_slot_t* slot;
- ulint i;
-
- mutex_enter(&kernel_mutex);
-
- for (i = 0; i < OS_THREAD_MAX_N; i++) {
-
- slot = srv_mysql_table + i;
-
- if (slot->in_use && slot->event == event) {
- /* Found */
- slot->in_use = FALSE;
- mutex_exit(&kernel_mutex);
-
- return;
- }
- }
-
- ut_a(0);
-}
-
/*************************************************************************
A thread which wakes up threads whose lock wait may have lasted too long. */
@@ -1924,6 +1851,7 @@ srv_master_thread(
ulint i;
time_t last_flush_time;
time_t current_time;
+ time_t last_monitor_time;
UT_NOT_USED(arg);
@@ -1936,6 +1864,8 @@ srv_master_thread(
mutex_exit(&kernel_mutex);
os_event_set(srv_sys->operational);
+
+ last_monitor_time = time(NULL);
loop:
mutex_enter(&kernel_mutex);
@@ -1975,8 +1905,18 @@ loop:
while (n_pages_purged) {
/* TODO: replace this by a check if we are running
out of file space! */
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB starts purge\n");
+ }
+
n_pages_purged = trx_purge();
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB purged %lu pages\n", n_pages_purged);
+ }
+
current_time = time(NULL);
if (difftime(current_time, last_flush_time) > 1) {
@@ -1986,14 +1926,40 @@ loop:
}
background_loop:
- /*
- sync_array_print_info(sync_primary_wait_array);
- os_aio_print();
- buf_print_io();
- */
/* In this loop we run background operations while the server
is quiet */
+ current_time = time(NULL);
+
+ if (srv_print_innodb_monitor
+ && difftime(current_time, last_monitor_time) > 8) {
+
+ printf("================================\n");
+ last_monitor_time = time(NULL);
+ ut_print_timestamp(stdout);
+
+ printf(" INNODB MONITOR OUTPUT\n"
+ "================================\n");
+ printf("--------------------------\n"
+ "LOCKS HELD BY TRANSACTIONS\n"
+ "--------------------------\n");
+ lock_print_info();
+ printf("-----------------------------------------------\n"
+ "CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS\n"
+ "-----------------------------------------------\n");
+ sync_print();
+ printf("CURRENT PENDING FILE I/O'S\n"
+ "--------------------------\n");
+ os_aio_print();
+ printf("-----------\n"
+ "BUFFER POOL\n"
+ "-----------\n");
+ buf_print_io();
+ printf("----------------------------\n"
+ "END OF INNODB MONITOR OUTPUT\n"
+ "============================\n");
+ }
+
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
mutex_exit(&kernel_mutex);
@@ -2005,8 +1971,18 @@ background_loop:
/* The server has been quiet for a while: start running background
operations */
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB starts purge\n");
+ }
+
n_pages_purged = trx_purge();
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB purged %lu pages\n", n_pages_purged);
+ }
+
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
mutex_exit(&kernel_mutex);
@@ -2014,8 +1990,18 @@ background_loop:
}
mutex_exit(&kernel_mutex);
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB starts insert buffer merge\n");
+ }
+
n_bytes_merged = ibuf_contract(TRUE);
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB merged %lu bytes\n", n_bytes_merged);
+ }
+
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
mutex_exit(&kernel_mutex);
@@ -2023,7 +2009,7 @@ background_loop:
}
mutex_exit(&kernel_mutex);
- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 20, ut_dulint_max);
+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
@@ -2052,14 +2038,12 @@ background_loop:
/* mem_print_new_info();
*/
-
-/* fsp_print(0); */
-
-/* fprintf(stderr, "Validating tablespace\n");
+/*
+ fsp_print(0);
+ fprintf(stderr, "Validating tablespace\n");
fsp_validate(0);
fprintf(stderr, "Validation ok\n");
*/
-
#ifdef UNIV_SEARCH_PERF_STAT
/* btr_search_print_info(); */
#endif
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index a343f2115e7..a79a808ba2e 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -1,7 +1,7 @@
/************************************************************************
Starts the InnoDB database server
-(c) 1996-2000 InnoDB Oy
+(c) 1996-2000 Innobase Oy
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
@@ -203,8 +203,8 @@ open_or_create_log_file(
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k], "ib_logfile", i);
- files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL, &ret);
-
+ files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
+ OS_LOG_FILE, &ret);
if (ret == FALSE) {
if (os_file_get_last_error() != OS_FILE_ALREADY_EXISTS) {
fprintf(stderr,
@@ -214,7 +214,8 @@ open_or_create_log_file(
}
files[i] = os_file_create(
- name, OS_FILE_OPEN, OS_FILE_AIO, &ret);
+ name, OS_FILE_OPEN, OS_FILE_AIO,
+ OS_LOG_FILE, &ret);
if (!ret) {
fprintf(stderr,
"InnoDB: Error in opening %s\n", name);
@@ -239,7 +240,7 @@ open_or_create_log_file(
fprintf(stderr,
"InnoDB: Log file %s did not exist: new to be created\n",
name);
- printf("InnoDB: Setting log file %s size to %lu\n",
+ fprintf(stderr, "InnoDB: Setting log file %s size to %lu\n",
name, UNIV_PAGE_SIZE * srv_log_file_size);
ret = os_file_set_size(name, files[i],
@@ -330,27 +331,28 @@ open_or_create_data_files(
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
- if (srv_data_file_is_raw_partition[i] == 0) {
-
- files[i] = os_file_create(name, OS_FILE_CREATE,
- OS_FILE_NORMAL, &ret);
- } else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
- ret = FALSE;
- } else if (srv_data_file_is_raw_partition[i] == SRV_NEW_RAW) {
+ files[i] = os_file_create(name, OS_FILE_CREATE,
+ OS_FILE_NORMAL, OS_DATA_FILE, &ret);
- files[i] = os_file_create(
- name, OS_FILE_OPEN, OS_FILE_NORMAL, &ret);
+ if (srv_data_file_is_raw_partition[i] == SRV_NEW_RAW) {
+ /* The partition is opened, not created; then it is
+ written over */
- if (!ret) {
+ files[i] = os_file_create(
+ name, OS_FILE_OPEN, OS_FILE_NORMAL,
+ OS_DATA_FILE, &ret);
+ if (!ret) {
fprintf(stderr,
"InnoDB: Error in opening %s\n", name);
return(DB_ERROR);
- }
+ }
+ } else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
+ ret = FALSE;
}
if (ret == FALSE) {
- if (srv_data_file_is_raw_partition[i] == 0
+ if (srv_data_file_is_raw_partition[i] != SRV_OLD_RAW
&& os_file_get_last_error() !=
OS_FILE_ALREADY_EXISTS) {
fprintf(stderr,
@@ -370,8 +372,8 @@ open_or_create_data_files(
}
files[i] = os_file_create(
- name, OS_FILE_OPEN, OS_FILE_NORMAL, &ret);
-
+ name, OS_FILE_OPEN, OS_FILE_NORMAL,
+ OS_DATA_FILE, &ret);
if (!ret) {
fprintf(stderr,
"InnoDB: Error in opening %s\n", name);
@@ -379,18 +381,21 @@ open_or_create_data_files(
return(DB_ERROR);
}
- ret = os_file_get_size(files[i], &size, &size_high);
- ut_a(ret);
+ if (srv_data_file_is_raw_partition[i] != SRV_OLD_RAW) {
+
+ ret = os_file_get_size(files[i], &size,
+ &size_high);
+ ut_a(ret);
- if (srv_data_file_is_raw_partition[i] == 0
- && (size != UNIV_PAGE_SIZE * srv_data_file_sizes[i]
- || size_high != 0)) {
-
- fprintf(stderr,
+ if (size !=
+ UNIV_PAGE_SIZE * srv_data_file_sizes[i]
+ || size_high != 0) {
+ fprintf(stderr,
"InnoDB: Error: data file %s is of different size\n"
"InnoDB: than specified in the .cnf file!\n", name);
- return(DB_ERROR);
+ return(DB_ERROR);
+ }
}
fil_read_flushed_lsn_and_arch_log_no(files[i],
@@ -403,7 +408,8 @@ open_or_create_data_files(
if (i > 0) {
fprintf(stderr,
- "InnoDB: Data file %s did not exist: new to be created\n", name);
+ "InnoDB: Data file %s did not exist: new to be created\n",
+ name);
} else {
fprintf(stderr,
"InnoDB: The first specified data file %s did not exist:\n"
@@ -411,10 +417,10 @@ open_or_create_data_files(
*create_new_db = TRUE;
}
- printf("InnoDB: Setting file %s size to %lu\n",
+ fprintf(stderr, "InnoDB: Setting file %s size to %lu\n",
name, UNIV_PAGE_SIZE * srv_data_file_sizes[i]);
- printf(
+ fprintf(stderr,
"InnoDB: Database physically writes the file full: wait...\n");
ret = os_file_set_size(name, files[i],
@@ -555,19 +561,22 @@ innobase_start_or_create_for_mysql(void)
srv_startup_is_before_trx_rollback_phase = TRUE;
if (0 == ut_strcmp(srv_unix_file_flush_method_str, "fdatasync")) {
- srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;
+ srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;
+
} else if (0 == ut_strcmp(srv_unix_file_flush_method_str, "O_DSYNC")) {
- srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
+ srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
+
} else if (0 == ut_strcmp(srv_unix_file_flush_method_str,
"littlesync")) {
- srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
+ srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
+
} else if (0 == ut_strcmp(srv_unix_file_flush_method_str, "nosync")) {
- srv_unix_file_flush_method = SRV_UNIX_NOSYNC;
+ srv_unix_file_flush_method = SRV_UNIX_NOSYNC;
} else {
- fprintf(stderr,
- "InnoDB: Unrecognized value for innodb_unix_file_flush_method\n");
-
- return(DB_ERROR);
+ fprintf(stderr,
+ "InnoDB: Unrecognized value %s for innodb_flush_method\n",
+ srv_unix_file_flush_method_str);
+ return(DB_ERROR);
}
/*
@@ -593,14 +602,15 @@ innobase_start_or_create_for_mysql(void)
#ifdef __WIN__
if (os_get_os_version() == OS_WIN95
|| os_get_os_version() == OS_WIN31) {
- /* On Win 95, 98, ME, and Win32 subsystem for Windows 3.1 use
- simulated aio */
- os_aio_use_native_aio = FALSE;
- srv_n_file_io_threads = 4;
+ /* On Win 95, 98, ME, and Win32 subsystem for Windows 3.1 use
+ simulated aio */
+
+ os_aio_use_native_aio = FALSE;
+ srv_n_file_io_threads = 4;
} else {
- /* On NT and Win 2000 always use aio */
- os_aio_use_native_aio = TRUE;
+ /* On NT and Win 2000 always use aio */
+ os_aio_use_native_aio = TRUE;
}
#endif
if (!os_aio_use_native_aio) {
@@ -652,14 +662,21 @@ innobase_start_or_create_for_mysql(void)
sum_of_new_sizes = 0;
for (i = 0; i < srv_n_data_files; i++) {
- sum_of_new_sizes += srv_data_file_sizes[i];
+ if (srv_data_file_sizes[i] >= 262144) {
+ fprintf(stderr,
+ "InnoDB: Error: file size must be < 4 GB, or on some OS's < 2 GB\n");
+
+ return(DB_ERROR);
+ }
+
+ sum_of_new_sizes += srv_data_file_sizes[i];
}
if (sum_of_new_sizes < 640) {
- fprintf(stderr,
+ fprintf(stderr,
"InnoDB: Error: tablespace size must be at least 10 MB\n");
- return(DB_ERROR);
+ return(DB_ERROR);
}
err = open_or_create_data_files(&create_new_db,
@@ -673,6 +690,15 @@ innobase_start_or_create_for_mysql(void)
return((int) err);
}
+ if (!create_new_db) {
+ /* If we are using the doublewrite method, we will
+ check if there are half-written pages in data files,
+ and restore them from the doublewrite buffer if
+ possible */
+
+ trx_sys_doublewrite_restore_corrupt_pages();
+ }
+
srv_normalize_path_for_win(srv_arch_dir);
srv_arch_dir = srv_add_path_separator_if_needed(srv_arch_dir);
@@ -742,7 +768,6 @@ innobase_start_or_create_for_mysql(void)
mutex_exit(&(log_sys->mutex));
}
- /* mutex_create(&row_mysql_thread_mutex); */
sess_sys_init_at_db_start();
if (create_new_db) {
@@ -834,7 +859,7 @@ innobase_start_or_create_for_mysql(void)
}
if (srv_measure_contention) {
- /* os_thread_create(&test_measure_cont, NULL, thread_ids +
+ /* os_thread_create(&test_measure_cont, NULL, thread_ids +
SRV_MAX_N_IO_THREADS); */
}
@@ -849,16 +874,20 @@ innobase_start_or_create_for_mysql(void)
/* Create the thread which watches the timeouts for lock waits */
os_thread_create(&srv_lock_timeout_monitor_thread, NULL,
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB: Started\n");
-
srv_was_started = TRUE;
srv_is_being_started = FALSE;
sync_order_checks_on = TRUE;
+ if (srv_use_doublewrite_buf && trx_doublewrite == NULL) {
+ trx_sys_create_doublewrite_buf();
+ }
+
/* buf_debug_prints = TRUE; */
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Started\n");
+
return((int) DB_SUCCESS);
}