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

updated

parent 65d4c846
...@@ -163,7 +163,7 @@ os_fast_mutex_trylock( ...@@ -163,7 +163,7 @@ os_fast_mutex_trylock(
#endif #endif
/************************************************************** /**************************************************************
Releases ownership of a fast mutex. */ Releases ownership of a fast mutex. */
UNIV_INLINE
void void
os_fast_mutex_unlock( os_fast_mutex_unlock(
/*=================*/ /*=================*/
......
...@@ -40,17 +40,3 @@ os_fast_mutex_trylock( ...@@ -40,17 +40,3 @@ os_fast_mutex_trylock(
} }
#endif #endif
/**************************************************************
Releases ownership of a fast mutex. */
UNIV_INLINE
void
os_fast_mutex_unlock(
/*=================*/
os_fast_mutex_t* fast_mutex) /* in: mutex to release */
{
#ifdef __WIN__
LeaveCriticalSection(fast_mutex);
#else
pthread_mutex_unlock(fast_mutex);
#endif
}
...@@ -66,6 +66,9 @@ extern char* srv_unix_file_flush_method_str; ...@@ -66,6 +66,9 @@ extern char* srv_unix_file_flush_method_str;
extern ulint srv_unix_file_flush_method; extern ulint srv_unix_file_flush_method;
extern ulint srv_force_recovery; extern ulint srv_force_recovery;
extern ulint srv_thread_concurrency; extern ulint srv_thread_concurrency;
extern lint srv_conc_n_threads;
extern ibool srv_fast_shutdown; extern ibool srv_fast_shutdown;
extern ibool srv_use_doublewrite_buf; extern ibool srv_use_doublewrite_buf;
......
...@@ -454,6 +454,21 @@ os_fast_mutex_lock( ...@@ -454,6 +454,21 @@ os_fast_mutex_lock(
#endif #endif
} }
/**************************************************************
Releases ownership of a fast mutex. */
void
os_fast_mutex_unlock(
/*=================*/
os_fast_mutex_t* fast_mutex) /* in: mutex to release */
{
#ifdef __WIN__
LeaveCriticalSection(fast_mutex);
#else
pthread_mutex_unlock(fast_mutex);
#endif
}
/************************************************************** /**************************************************************
Frees a mutex object. */ Frees a mutex object. */
......
...@@ -946,11 +946,27 @@ row_create_table_for_mysql( ...@@ -946,11 +946,27 @@ row_create_table_for_mysql(
"InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n"
"InnoDB: with raw, and innodb_force_... is removed.\n"); "InnoDB: with raw, and innodb_force_... is removed.\n");
trx_commit_for_mysql(trx);
return(DB_ERROR); return(DB_ERROR);
} }
trx->op_info = "creating table"; trx->op_info = "creating table";
if (0 == ut_strcmp(table->name, "mysql/host")
|| 0 == ut_strcmp(table->name, "mysql/user")
|| 0 == ut_strcmp(table->name, "mysql/db")) {
fprintf(stderr,
"InnoDB: Error: trying to create a MySQL system table %s of type InnoDB.\n"
"InnoDB: MySQL system tables must be of the MyISAM type!\n",
table->name);
trx_commit_for_mysql(trx);
return(DB_ERROR);
}
trx_start_if_not_started(trx); trx_start_if_not_started(trx);
namelen = ut_strlen(table->name); namelen = ut_strlen(table->name);
...@@ -1423,6 +1439,8 @@ row_drop_table_for_mysql( ...@@ -1423,6 +1439,8 @@ row_drop_table_for_mysql(
que_graph_free(graph); que_graph_free(graph);
trx_commit_for_mysql(trx);
trx->op_info = ""; trx->op_info = "";
return((int) err); return((int) err);
...@@ -1508,6 +1526,20 @@ row_rename_table_for_mysql( ...@@ -1508,6 +1526,20 @@ row_rename_table_for_mysql(
"InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n"
"InnoDB: with raw, and innodb_force_... is removed.\n"); "InnoDB: with raw, and innodb_force_... is removed.\n");
trx_commit_for_mysql(trx);
return(DB_ERROR);
}
if (0 == ut_strcmp(new_name, "mysql/host")
|| 0 == ut_strcmp(new_name, "mysql/user")
|| 0 == ut_strcmp(new_name, "mysql/db")) {
fprintf(stderr,
"InnoDB: Error: trying to create a MySQL system table %s of type InnoDB.\n"
"InnoDB: MySQL system tables must be of the MyISAM type!\n",
new_name);
trx_commit_for_mysql(trx);
return(DB_ERROR); return(DB_ERROR);
} }
...@@ -1591,6 +1623,8 @@ row_rename_table_for_mysql( ...@@ -1591,6 +1623,8 @@ row_rename_table_for_mysql(
que_graph_free(graph); que_graph_free(graph);
trx_commit_for_mysql(trx);
trx->op_info = ""; trx->op_info = "";
return((int) err); return((int) err);
......
...@@ -121,12 +121,17 @@ semaphore contention and convoy problems can occur withput this restriction. ...@@ -121,12 +121,17 @@ semaphore contention and convoy problems can occur withput this restriction.
Value 10 should be good if there are less than 4 processors + 4 disks in the Value 10 should be good if there are less than 4 processors + 4 disks in the
computer. Bigger computers need bigger values. */ computer. Bigger computers need bigger values. */
ulint srv_thread_concurrency = 4; ulint srv_thread_concurrency = 8;
os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data
structures */ structures */
ulint srv_conc_n_threads = 0; /* number of OS threads currently lint srv_conc_n_threads = 0; /* number of OS threads currently
inside InnoDB */ inside InnoDB; it is not an error
if this drops temporarily below zero
because we do not demand that every
thread increments this, but a thread
waiting for a lock decrements this
temporarily */
typedef struct srv_conc_slot_struct srv_conc_slot_t; typedef struct srv_conc_slot_struct srv_conc_slot_t;
struct srv_conc_slot_struct{ struct srv_conc_slot_struct{
...@@ -1637,7 +1642,7 @@ srv_conc_enter_innodb( ...@@ -1637,7 +1642,7 @@ srv_conc_enter_innodb(
os_fast_mutex_lock(&srv_conc_mutex); os_fast_mutex_lock(&srv_conc_mutex);
if (srv_conc_n_threads < srv_thread_concurrency) { if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
srv_conc_n_threads++; srv_conc_n_threads++;
os_fast_mutex_unlock(&srv_conc_mutex); os_fast_mutex_unlock(&srv_conc_mutex);
...@@ -1645,7 +1650,7 @@ srv_conc_enter_innodb( ...@@ -1645,7 +1650,7 @@ srv_conc_enter_innodb(
return; return;
} }
/* Too many threads inside: put to the current thread to a queue */ /* Too many threads inside: put the current thread to a queue */
for (i = 0; i < OS_THREAD_MAX_N; i++) { for (i = 0; i < OS_THREAD_MAX_N; i++) {
slot = srv_conc_slots + i; slot = srv_conc_slots + i;
...@@ -1725,11 +1730,9 @@ srv_conc_exit_innodb(void) ...@@ -1725,11 +1730,9 @@ srv_conc_exit_innodb(void)
os_fast_mutex_lock(&srv_conc_mutex); os_fast_mutex_lock(&srv_conc_mutex);
ut_a(srv_conc_n_threads > 0);
srv_conc_n_threads--; srv_conc_n_threads--;
if (srv_conc_n_threads < srv_thread_concurrency) { if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
/* Look for a slot where a thread is waiting and no other /* Look for a slot where a thread is waiting and no other
thread has yet released the thread */ thread has yet released the thread */
...@@ -1976,16 +1979,18 @@ srv_lock_timeout_and_monitor_thread( ...@@ -1976,16 +1979,18 @@ srv_lock_timeout_and_monitor_thread(
void* arg) /* in: a dummy parameter required by void* arg) /* in: a dummy parameter required by
os_thread_create */ os_thread_create */
{ {
srv_slot_t* slot;
double time_elapsed; double time_elapsed;
time_t current_time; time_t current_time;
time_t last_monitor_time; time_t last_monitor_time;
time_t last_table_monitor_time;
ibool some_waits; ibool some_waits;
srv_slot_t* slot;
double wait_time; double wait_time;
ulint i; ulint i;
UT_NOT_USED(arg); UT_NOT_USED(arg);
last_monitor_time = time(NULL); last_monitor_time = time(NULL);
last_table_monitor_time = time(NULL);
loop: loop:
srv_lock_timeout_and_monitor_active = TRUE; srv_lock_timeout_and_monitor_active = TRUE;
...@@ -2047,7 +2052,7 @@ srv_lock_timeout_and_monitor_thread( ...@@ -2047,7 +2052,7 @@ srv_lock_timeout_and_monitor_thread(
"ROW OPERATIONS\n" "ROW OPERATIONS\n"
"--------------\n"); "--------------\n");
printf( printf(
"%lu queries inside InnoDB; main thread: %s\n", "%ld queries inside InnoDB; main thread: %s\n",
srv_conc_n_threads, srv_main_thread_op_info); srv_conc_n_threads, srv_main_thread_op_info);
printf( printf(
"Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n", "Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n",
...@@ -2074,11 +2079,12 @@ srv_lock_timeout_and_monitor_thread( ...@@ -2074,11 +2079,12 @@ srv_lock_timeout_and_monitor_thread(
printf("----------------------------\n" printf("----------------------------\n"
"END OF INNODB MONITOR OUTPUT\n" "END OF INNODB MONITOR OUTPUT\n"
"============================\n"); "============================\n");
} }
if (srv_print_innodb_tablespace_monitor) { if (srv_print_innodb_tablespace_monitor
&& difftime(current_time, last_table_monitor_time) > 60) {
last_table_monitor_time = time(NULL);
printf("================================================\n"); printf("================================================\n");
...@@ -2096,7 +2102,10 @@ srv_lock_timeout_and_monitor_thread( ...@@ -2096,7 +2102,10 @@ srv_lock_timeout_and_monitor_thread(
"=======================================\n"); "=======================================\n");
} }
if (srv_print_innodb_table_monitor) { if (srv_print_innodb_table_monitor
&& difftime(current_time, last_table_monitor_time) > 60) {
last_table_monitor_time = time(NULL);
printf("===========================================\n"); printf("===========================================\n");
...@@ -2200,6 +2209,12 @@ srv_error_monitor_thread( ...@@ -2200,6 +2209,12 @@ srv_error_monitor_thread(
sync_array_print_long_waits(); sync_array_print_long_waits();
/* Flush stdout and stderr so that a database user gets their output
to possible MySQL error file */
fflush(stderr);
fflush(stdout);
if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) { if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) {
goto loop; goto loop;
......
...@@ -996,6 +996,13 @@ innobase_shutdown_for_mysql(void) ...@@ -996,6 +996,13 @@ innobase_shutdown_for_mysql(void)
logs_empty_and_mark_files_at_shutdown(); logs_empty_and_mark_files_at_shutdown();
if (srv_conc_n_threads != 0) {
fprintf(stderr,
"InnoDB: Warning: query counter shows %ld queries still\n"
"InnoDB: inside InnoDB at shutdown\n",
srv_conc_n_threads);
}
ut_free_all_mem(); ut_free_all_mem();
return((int) DB_SUCCESS); return((int) DB_SUCCESS);
......
...@@ -1466,7 +1466,9 @@ ha_innobase::write_row( ...@@ -1466,7 +1466,9 @@ ha_innobase::write_row(
The lock is released at each SQL statement's The lock is released at each SQL statement's
end. */ end. */
srv_conc_enter_innodb(prebuilt->trx);
error = row_lock_table_autoinc_for_mysql(prebuilt); error = row_lock_table_autoinc_for_mysql(prebuilt);
srv_conc_exit_innodb();
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
...@@ -1517,7 +1519,9 @@ ha_innobase::write_row( ...@@ -1517,7 +1519,9 @@ ha_innobase::write_row(
auto_inc = table->next_number_field->val_int(); auto_inc = table->next_number_field->val_int();
srv_conc_enter_innodb(prebuilt->trx);
error = row_lock_table_autoinc_for_mysql(prebuilt); error = row_lock_table_autoinc_for_mysql(prebuilt);
srv_conc_exit_innodb();
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
...@@ -2799,6 +2803,8 @@ ha_innobase::delete_table( ...@@ -2799,6 +2803,8 @@ ha_innobase::delete_table(
srv_active_wake_master_thread(); srv_active_wake_master_thread();
trx_commit_for_mysql(trx);
trx_free_for_mysql(trx); trx_free_for_mysql(trx);
error = convert_error_code_to_mysql(error); error = convert_error_code_to_mysql(error);
...@@ -2852,6 +2858,7 @@ innobase_drop_database( ...@@ -2852,6 +2858,7 @@ innobase_drop_database(
srv_active_wake_master_thread(); srv_active_wake_master_thread();
trx_commit_for_mysql(trx);
trx_free_for_mysql(trx); trx_free_for_mysql(trx);
error = convert_error_code_to_mysql(error); error = convert_error_code_to_mysql(error);
...@@ -2904,6 +2911,7 @@ ha_innobase::rename_table( ...@@ -2904,6 +2911,7 @@ ha_innobase::rename_table(
srv_active_wake_master_thread(); srv_active_wake_master_thread();
trx_commit_for_mysql(trx);
trx_free_for_mysql(trx); trx_free_for_mysql(trx);
error = convert_error_code_to_mysql(error); error = convert_error_code_to_mysql(error);
......
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