summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-06-01 23:40:01 +0300
committerunknown <monty@narttu.mysql.fi>2003-06-01 23:40:01 +0300
commit3f7dfc4df3a9bdfc01e5b84c3297fff61b791f9b (patch)
tree3c4881fc77893b5cb3c764a11bac310e21a0ce77
parent782da113cb6baab6e37daa94dc828e9f14111933 (diff)
downloadmariadb-git-3f7dfc4df3a9bdfc01e5b84c3297fff61b791f9b.tar.gz
Small fixes (nothing nameworthy)
mysql-test/r/errors.result: Rename: mysql-test/r/err000001.result -> mysql-test/r/errors.result include/my_global.h: typedef for future functions that needs string length as an argument innobase/os/os0file.c: Added operation to error messages mysql-test/t/errors.test: Cleaned up file to new error number standard mysys/thr_alarm.c: Made end_thr_alarm() work also with internal alarm thread. (Not critical for MySQL) sql/mysqld.cc: Added sigemptyset() (bug found by valgrind) Removed some wrong usage of thd when writing variable values
-rw-r--r--include/my_global.h5
-rw-r--r--innobase/os/os0file.c37
-rw-r--r--mysql-test/r/errors.result (renamed from mysql-test/r/err000001.result)0
-rw-r--r--mysql-test/t/err000001.test19
-rw-r--r--mysql-test/t/errors.test32
-rw-r--r--mysys/thr_alarm.c41
-rw-r--r--sql/mysqld.cc14
7 files changed, 95 insertions, 53 deletions
diff --git a/include/my_global.h b/include/my_global.h
index d892d843edc..90c4801e807 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (C) 2000-2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -640,6 +640,9 @@ typedef long my_ptrdiff_t;
typedef long long my_ptrdiff_t;
#endif
+/* typedef used for length of string; Should be unsigned! */
+typedef ulong size_str;
+
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
/* Size to make adressable obj. */
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 640ffec122f..00e29121ece 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -295,7 +295,8 @@ os_file_handle_error(
/* out: TRUE if we should retry the
operation */
os_file_t file, /* in: file pointer */
- char* name) /* in: name of a file or NULL */
+ char* name, /* in: name of a file or NULL */
+ const char* operation) /* in: type of operation */
{
ulint err;
@@ -337,7 +338,8 @@ os_file_handle_error(
if (name) {
fprintf(stderr, "InnoDB: File name %s\n", name);
}
-
+ fprintf(stderr, "InnoDB: system call %s\n", operation);
+
fprintf(stderr, "InnoDB: Cannot continue operation.\n");
fflush(stderr);
@@ -419,7 +421,9 @@ try_again:
if (file == INVALID_HANDLE_VALUE) {
*success = FALSE;
- retry = os_file_handle_error(file, name);
+ retry = os_file_handle_error(file, name,
+ create_mode == OS_FILE_OPEN ?
+ "open" : "create");
if (retry) {
goto try_again;
@@ -460,7 +464,10 @@ try_again:
if (file == -1) {
*success = FALSE;
- retry = os_file_handle_error(file, name);
+ retry = os_file_handle_error(file, name,
+ create_mode == OS_FILE_OPEN ?
+ "open" : "create");
+
if (retry) {
goto try_again;
@@ -568,7 +575,9 @@ try_again:
if (file == INVALID_HANDLE_VALUE) {
*success = FALSE;
- retry = os_file_handle_error(file, name);
+ retry = os_file_handle_error(file, name,
+ create_mode == OS_FILE_OPEN ?
+ "open" : "create");
if (retry) {
goto try_again;
@@ -615,7 +624,9 @@ try_again:
if (file == -1) {
*success = FALSE;
- retry = os_file_handle_error(file, name);
+ retry = os_file_handle_error(file, name,
+ create_mode == OS_FILE_OPEN ?
+ "open" : "create");
if (retry) {
goto try_again;
@@ -649,7 +660,7 @@ os_file_close(
return(TRUE);
}
- os_file_handle_error(file, NULL);
+ os_file_handle_error(file, NULL, "close");
return(FALSE);
#else
int ret;
@@ -657,7 +668,7 @@ os_file_close(
ret = close(file);
if (ret == -1) {
- os_file_handle_error(file, NULL);
+ os_file_handle_error(file, NULL, "close");
return(FALSE);
}
@@ -825,7 +836,7 @@ os_file_flush(
return(TRUE);
}
- os_file_handle_error(file, NULL);
+ os_file_handle_error(file, NULL, "flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
@@ -858,7 +869,7 @@ os_file_flush(
fprintf(stderr,
" InnoDB: Error: the OS said file flush did not succeed\n");
- os_file_handle_error(file, NULL);
+ os_file_handle_error(file, NULL, "flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
@@ -1099,7 +1110,7 @@ try_again:
#ifdef __WIN__
error_handling:
#endif
- retry = os_file_handle_error(file, NULL);
+ retry = os_file_handle_error(file, NULL, "read");
if (retry) {
goto try_again;
@@ -2014,7 +2025,7 @@ try_again:
os_aio_array_free_slot(array, slot);
- retry = os_file_handle_error(file, name);
+ retry = os_file_handle_error(file, name, "aio");
if (retry) {
@@ -2113,7 +2124,7 @@ os_aio_windows_handle(
ut_a(TRUE == os_file_flush(slot->file));
}
} else {
- os_file_handle_error(slot->file, slot->name);
+ os_file_handle_error(slot->file, slot->name, "aio");
ret_val = FALSE;
}
diff --git a/mysql-test/r/err000001.result b/mysql-test/r/errors.result
index 5afecc6d600..5afecc6d600 100644
--- a/mysql-test/r/err000001.result
+++ b/mysql-test/r/errors.result
diff --git a/mysql-test/t/err000001.test b/mysql-test/t/err000001.test
deleted file mode 100644
index d9898054a83..00000000000
--- a/mysql-test/t/err000001.test
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Test some error conditions
-#
-
-drop table if exists t1;
-!$1146 insert into t1 values(1);
-!$1146 delete from t1;
-!$1146 update t1 set a=1;
-create table t1 (a int);
-!$1054 select count(test.t1.b) from t1;
-!$1109 select count(not_existing_database.t1) from t1;
-!$1109 select count(not_existing_database.t1.a) from t1;
---error 1044,1146
-select count(not_existing_database.t1.a) from not_existing_database.t1;
-!$1054 select 1 from t1 order by 2;
-!$1054 select 1 from t1 group by 2;
-!$1054 select 1 from t1 order by t1.b;
-!$1054 select count(*),b from t1;
-drop table t1;
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
new file mode 100644
index 00000000000..afb0cce9005
--- /dev/null
+++ b/mysql-test/t/errors.test
@@ -0,0 +1,32 @@
+#
+# Test some error conditions
+#
+
+drop table if exists t1;
+--error 1146
+insert into t1 values(1);
+--error 1146
+delete from t1;
+--error 1146
+update t1 set a=1;
+
+#
+
+create table t1 (a int);
+--error 1054
+select count(test.t1.b) from t1;
+--error 1109
+select count(not_existing_database.t1) from t1;
+--error 1109
+ select count(not_existing_database.t1.a) from t1;
+--error 1044,1146
+select count(not_existing_database.t1.a) from not_existing_database.t1;
+--error 1054
+select 1 from t1 order by 2;
+--error 1054
+select 1 from t1 group by 2;
+--error 1054
+select 1 from t1 order by t1.b;
+--error 1054
+select count(*),b from t1;
+drop table t1;
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index ca8e4e8bcb6..a2647ec7399 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -38,20 +38,21 @@
#endif
static int alarm_aborted=1; /* No alarm thread */
-my_bool thr_alarm_inited=0;
+my_bool thr_alarm_inited= 0;
+volatile my_bool alarm_thread_running= 0;
static sig_handler process_alarm_part2(int sig);
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
static pthread_mutex_t LOCK_alarm;
+static pthread_cond_t COND_alarm;
static sigset_t full_signal_set;
static QUEUE alarm_queue;
static uint max_used_alarms=0;
pthread_t alarm_thread;
#ifdef USE_ALARM_THREAD
-static pthread_cond_t COND_alarm;
static void *alarm_handler(void *arg);
#define reschedule_alarms() pthread_cond_signal(&COND_alarm)
#else
@@ -78,6 +79,7 @@ void init_thr_alarm(uint max_alarms)
compare_ulong,NullS);
sigfillset(&full_signal_set); /* Neaded to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
+ pthread_cond_init(&COND_alarm,NULL);
#if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
#if defined(HAVE_mit_thread)
sigset(THR_CLIENT_ALARM,thread_alarm); /* int. thread system calls */
@@ -97,7 +99,6 @@ void init_thr_alarm(uint max_alarms)
{
pthread_attr_t thr_attr;
pthread_attr_init(&thr_attr);
- pthread_cond_init(&COND_alarm,NULL);
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&thr_attr,8196);
@@ -383,28 +384,45 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
void end_thr_alarm(my_bool free_structures)
{
DBUG_ENTER("end_thr_alarm");
- if (alarm_aborted != 1)
+ if (alarm_aborted != 1) /* If memory not freed */
{
pthread_mutex_lock(&LOCK_alarm);
DBUG_PRINT("info",("Resheduling %d waiting alarms",alarm_queue.elements));
alarm_aborted= -1; /* mark aborted */
- if (pthread_equal(pthread_self(),alarm_thread))
- alarm(1); /* Shut down everything soon */
- else
- reschedule_alarms();
+ if (alarm_queue.elements || (alarm_thread_running && free_structures))
+ {
+ if (pthread_equal(pthread_self(),alarm_thread))
+ alarm(1); /* Shut down everything soon */
+ else
+ reschedule_alarms();
+ }
if (free_structures)
{
+ struct timespec abstime;
/*
The following test is just for safety, the caller should not
depend on this
*/
DBUG_ASSERT(!alarm_queue.elements);
+ /* Wait until alarm thread dies */
+
+ set_timespec(abstime, 10); /* Wait up to 10 seconds */
+ while (alarm_thread_running)
+ {
+ int error= pthread_cond_timedwait(&COND_alarm, &LOCK_alarm, &abstime);
+ if (error == ETIME || error == ETIMEDOUT)
+ break; /* Don't wait forever */
+ }
if (!alarm_queue.elements)
{
delete_queue(&alarm_queue);
alarm_aborted= 1;
pthread_mutex_unlock(&LOCK_alarm);
- pthread_mutex_destroy(&LOCK_alarm);
+ if (!alarm_thread_running) /* Safety */
+ {
+ pthread_mutex_destroy(&LOCK_alarm);
+ pthread_cond_destroy(&COND_alarm);
+ }
}
}
else
@@ -490,6 +508,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
puts("Starting alarm thread");
#endif
my_thread_init();
+ alarm_thread_running= 1;
pthread_mutex_lock(&LOCK_alarm);
for (;;)
{
@@ -514,7 +533,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
}
}
}
- else if (alarm_aborted)
+ else if (alarm_aborted == -1)
break;
else if ((error=pthread_cond_wait(&COND_alarm,&LOCK_alarm)))
{
@@ -526,6 +545,8 @@ static void *alarm_handler(void *arg __attribute__((unused)))
process_alarm(0);
}
bzero((char*) &alarm_thread,sizeof(alarm_thread)); /* For easy debugging */
+ alarm_thread_running= 0;
+ pthread_cond_signal(&COND_alarm);
pthread_mutex_unlock(&LOCK_alarm);
pthread_exit(0);
return 0; /* Impossible */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index c2ee940af49..1492d6ddb68 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1520,7 +1520,6 @@ the problem, but since we have already crashed, something is definitely wrong\n\
and this may fail.\n\n");
fprintf(stderr, "key_buffer_size=%lu\n", (ulong) keybuff_size);
fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size);
- fprintf(stderr, "sort_buffer_size=%ld\n", thd->variables.sortbuff_size);
fprintf(stderr, "max_used_connections=%ld\n", max_used_connections);
fprintf(stderr, "max_connections=%ld\n", max_connections);
fprintf(stderr, "threads_connected=%d\n", thread_count);
@@ -1528,7 +1527,7 @@ and this may fail.\n\n");
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\
bytes of memory\n", ((ulong) keybuff_size +
(global_system_variables.read_buff_size +
- thd->variables.sortbuff_size) *
+ global_system_variables.sortbuff_size) *
max_connections)/ 1024);
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
@@ -1557,14 +1556,9 @@ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n",
Some pointers may be invalid and cause the dump to abort...\n");
safe_print_str("thd->query", thd->query, 1024);
fprintf(stderr, "thd->thread_id=%ld\n", thd->thread_id);
- fprintf(stderr, "\n\
-Successfully dumped variables, if you ran with --log, take a look at the\n\
-details of what thread %ld did to cause the crash. In some cases of really\n\
-bad corruption, the values shown above may be invalid.\n\n",
- thd->thread_id);
}
fprintf(stderr, "\
-The manual page at http://www.mysql.com/doc/C/r/Crashing.html contains\n\
+The manual page at http://www.mysql.com/doc/en/Crashing.html contains\n\
information that should help you find out what is causing the crash.\n");
fflush(stderr);
#endif /* HAVE_STACKTRACE */
@@ -1639,6 +1633,7 @@ static void init_signals(void)
sigaddset(&set,SIGHUP);
/* Fix signals if blocked by parents (can happen on Mac OS X) */
+ sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = print_signal_warning;
sigaction(SIGTERM, &sa, (struct sigaction*) 0);
@@ -2279,7 +2274,7 @@ int main(int argc, char **argv)
#endif
/* init_slave() must be called after the thread keys are created */
init_slave();
-
+
DBUG_ASSERT(current_thd == 0);
if (opt_bin_log && !server_id)
{
@@ -2307,7 +2302,6 @@ The server will not act as a slave.");
using_update_log=1;
}
-
if (opt_bootstrap)
{
int error=bootstrap(stdin);