summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@mysqlwin32.>2008-02-06 18:02:05 +0100
committerunknown <guilhem@mysqlwin32.>2008-02-06 18:02:05 +0100
commit7300af848a5a1c6e75e909657c172af8c8169831 (patch)
treeb22678c1d5900afb2e06d101ec88712e09982a90
parent211a9e72a910b9707349ba4242e80eb9c5694d56 (diff)
downloadmariadb-git-7300af848a5a1c6e75e909657c172af8c8169831.tar.gz
Fixes for running maria-recovery*.test and maria-purge.test under
Windows. include/my_dbug.h: a DBUG expression to force a flush of the trace file then an abort of the process mysql-test/include/wait_until_connected_again.inc: mysqladmin waits for pid file to be gone only under Unix; so maria_empty_logs.inc cannot wait for mysqld to be gone, so wait_until_connected_again.inc may send its "show status" to a not-yet-dead server hence the 1053 error ("server shutdown in progress") mysys/my_thr_init.c: overload abort() under Windows, to not have an annoying CRT popup ("ignore/abort/retry" buttons) each time a test intentionally crashes mysqld sql/handler.cc: use new expression sql/log.cc: use new expression sql/mysql_priv.h: use new expression storage/maria/ha_maria.cc: use new expression storage/maria/ma_blockrec.c: use new expression storage/maria/ma_check.c: use new expression storage/maria/ma_checkpoint.c: use new expression storage/maria/ma_control_file.c: Can't yet lock control file under Windows (test suite problems, plus concerns about stray lock preventing a fast restart after crash). storage/maria/ma_loghandler.c: A file which should be closed, otherwise translog_purge() (the caller) cannot delete logs.
-rw-r--r--include/my_dbug.h2
-rw-r--r--mysql-test/include/wait_until_connected_again.inc2
-rw-r--r--mysys/my_thr_init.c15
-rw-r--r--sql/handler.cc10
-rw-r--r--sql/log.cc2
-rw-r--r--sql/mysql_priv.h4
-rw-r--r--storage/maria/ha_maria.cc3
-rw-r--r--storage/maria/ma_blockrec.c6
-rw-r--r--storage/maria/ma_check.c9
-rw-r--r--storage/maria/ma_checkpoint.c6
-rw-r--r--storage/maria/ma_control_file.c14
-rw-r--r--storage/maria/ma_loghandler.c11
12 files changed, 54 insertions, 30 deletions
diff --git a/include/my_dbug.h b/include/my_dbug.h
index a284e648f7f..6b197ebf0e1 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -85,6 +85,7 @@ extern void _db_force_flush();
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
#define IF_DBUG(A) A
+#define DBUG_ABORT() ((void)fflush(DBUG_FILE), abort())
#else /* No debugger */
#define DBUG_ENTER(a1)
@@ -114,6 +115,7 @@ extern void _db_force_flush();
#define DEBUGGER_OFF do { } while(0)
#define DEBUGGER_ON do { } while(0)
#define IF_DBUG(A)
+#define DBUG_ABORT() ((void)(0))
#endif
#ifdef __cplusplus
}
diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc
index 3d8a6212c34..02d544cb966 100644
--- a/mysql-test/include/wait_until_connected_again.inc
+++ b/mysql-test/include/wait_until_connected_again.inc
@@ -8,7 +8,7 @@ let $counter= 5000;
let $mysql_errno= 1;
while ($mysql_errno)
{
- --error 0,2002,2003,2006
+ --error 0,2002,2003,2006,1053
show status;
dec $counter;
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index aadb86d39ed..f4c7f607a45 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -444,3 +444,18 @@ static uint get_thread_lib(void)
}
#endif /* THREAD */
+
+
+#ifdef __WIN__
+/*
+ With Windows debug builds abort() causes a popup from CRT; as abort()
+ is used in tests it is annoying so we use a custom one.
+*/
+void abort(void)
+{
+#ifdef REENABLE_AFTER_FIX_FOR_BUG_31745 /* don't want a popup */
+ raise(SIGABRT);
+#endif
+ _exit(3);
+}
+#endif
diff --git a/sql/handler.cc b/sql/handler.cc
index 6489041eaf1..da789ef2544 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -719,7 +719,7 @@ int ha_commit_trans(THD *thd, bool all)
goto end;
}
- DBUG_EXECUTE_IF("crash_commit_before", abort(););
+ DBUG_EXECUTE_IF("crash_commit_before", DBUG_ABORT(););
/* Close all cursors that can not survive COMMIT */
if (is_real_trans) /* not a statement commit */
@@ -737,7 +737,7 @@ int ha_commit_trans(THD *thd, bool all)
}
status_var_increment(thd->status_var.ha_prepare_count);
}
- DBUG_EXECUTE_IF("crash_commit_after_prepare", abort(););
+ DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_ABORT(););
if (error || (is_real_trans && xid &&
(error= !(cookie= tc_log->log_xid(thd, xid)))))
{
@@ -745,13 +745,13 @@ int ha_commit_trans(THD *thd, bool all)
error= 1;
goto end;
}
- DBUG_EXECUTE_IF("crash_commit_after_log", abort(););
+ DBUG_EXECUTE_IF("crash_commit_after_log", DBUG_ABORT(););
}
error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0;
- DBUG_EXECUTE_IF("crash_commit_before_unlog", abort(););
+ DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_ABORT(););
if (cookie)
tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
+ DBUG_EXECUTE_IF("crash_commit_after", DBUG_ABORT(););
end:
if (is_real_trans)
start_waiting_global_read_lock(thd);
diff --git a/sql/log.cc b/sql/log.cc
index a0c35059902..3c2251f9b69 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -4049,7 +4049,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
goto err;
if (flush_and_sync())
goto err;
- DBUG_EXECUTE_IF("half_binlogged_transaction", abort(););
+ DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_ABORT(););
if (cache->error) // Error on read
{
sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno);
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index cb12e50e054..4d6f24d3713 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -930,7 +930,7 @@ check_and_unset_inject_value(int value)
#define SET_ERROR_INJECT_VALUE(x) \
current_thd->error_inject_value= (x)
#define ERROR_INJECT_CRASH(code) \
- DBUG_EVALUATE_IF(code, (abort(), 0), 0)
+ DBUG_EVALUATE_IF(code, (DBUG_ABORT(), 0), 0)
#define ERROR_INJECT_ACTION(code, action) \
(check_and_unset_keyword(code) ? ((action), 0) : 0)
#define ERROR_INJECT(code) \
@@ -940,7 +940,7 @@ check_and_unset_inject_value(int value)
#define ERROR_INJECT_VALUE_ACTION(value,action) \
(check_and_unset_inject_value(value) ? (action) : 0)
#define ERROR_INJECT_VALUE_CRASH(value) \
- ERROR_INJECT_VALUE_ACTION(value, (abort(), 0))
+ ERROR_INJECT_VALUE_ACTION(value, (DBUG_ABORT(), 0))
#endif
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 7f8f985354b..6860e5a3ea4 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1677,8 +1677,7 @@ int ha_maria::enable_indexes(uint mode)
DBUG_EXECUTE_IF("maria_crash_enable_index",
{
DBUG_PRINT("maria_crash_enable_index", ("now"));
- fflush(DBUG_FILE);
- abort();
+ DBUG_ABORT();
});
return error;
}
diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c
index f4e59fe34e0..ffe96424de3 100644
--- a/storage/maria/ma_blockrec.c
+++ b/storage/maria/ma_blockrec.c
@@ -2864,11 +2864,7 @@ static my_bool write_block_record(MARIA_HA *info,
translog_flush(translog_get_horizon());
});
DBUG_EXECUTE_IF("maria_crash",
- {
- DBUG_PRINT("maria_crash", ("now"));
- fflush(DBUG_FILE);
- abort();
- });
+ { DBUG_PRINT("maria_crash", ("now")); DBUG_ABORT(); });
}
#endif
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index cee1e7a9b65..01edc98e88a 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -2813,8 +2813,7 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
DBUG_EXECUTE_IF("maria_crash_sort_index",
{
DBUG_PRINT("maria_crash_sort_index", ("now"));
- fflush(DBUG_FILE);
- abort();
+ DBUG_ABORT();
});
DBUG_RETURN(0);
@@ -3453,8 +3452,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
DBUG_EXECUTE_IF("maria_crash_create_index_by_sort",
{
DBUG_PRINT("maria_crash_create_index_by_sort", ("now"));
- fflush(DBUG_FILE);
- abort();
+ DBUG_ABORT();
});
if (scan_inited)
{
@@ -3650,8 +3648,7 @@ err:
DBUG_EXECUTE_IF("maria_crash_repair",
{
DBUG_PRINT("maria_crash_repair", ("now"));
- fflush(DBUG_FILE);
- abort();
+ DBUG_ABORT();
});
}
share->state.changed|= STATE_NOT_SORTED_PAGES;
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index be21ec121a5..33f7176fc08 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -419,11 +419,7 @@ void ma_checkpoint_end(void)
flush_all_tables(1);
});
DBUG_EXECUTE_IF("maria_crash",
- {
- DBUG_PRINT("maria_crash", ("now"));
- fflush(DBUG_FILE);
- abort();
- });
+ { DBUG_PRINT("maria_crash", ("now")); DBUG_ABORT(); });
if (checkpoint_inited)
{
diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c
index 13e159e92d5..deda5e023c7 100644
--- a/storage/maria/ma_control_file.c
+++ b/storage/maria/ma_control_file.c
@@ -351,10 +351,19 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
retry= 0;
/*
+ On Windows, my_lock() uses locking() which is mandatory locking and so
+ prevents maria-recovery.test from copying the control file. And in case of
+ crash, it may take a while for Windows to unlock file, causing downtime.
+ */
+ /**
+ @todo BUG We should explore my_sopen(_SH_DENYWRD) to open or create the
+ file under Windows.
+ */
+#ifndef __WIN__
+ /*
We can't here use the automatic wait in my_lock() as the alarm thread
may not yet exists.
*/
-
while (my_lock(control_file_fd, F_WRLCK, 0L, F_TO_EOF,
MYF(MY_SEEK_NOT_DONE | MY_FORCE_LOCK | MY_NO_WAIT)))
{
@@ -370,6 +379,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
}
sleep(1);
}
+#endif
DBUG_RETURN(0);
@@ -487,8 +497,10 @@ int ma_control_file_end()
if (control_file_fd < 0) /* already closed */
DBUG_RETURN(0);
+#ifndef __WIN__
(void) my_lock(control_file_fd, F_UNLCK, 0L, F_TO_EOF,
MYF(MY_SEEK_NOT_DONE | MY_FORCE_LOCK));
+#endif
close_error= my_close(control_file_fd, MYF(MY_WME));
/*
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index 9f36366a798..5a98d9d0d03 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -1314,9 +1314,16 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
{
LOGHANDLER_FILE_INFO info;
+ my_bool error;
File fd= open_logfile_by_number_no_cache(file);
- if (fd < 0 ||
- translog_read_file_header(&info, fd))
+ if (fd >= 0)
+ {
+ error= translog_read_file_header(&info, fd);
+ my_close(fd, MYF(MY_WME));
+ }
+ else
+ error= TRUE;
+ if (error)
{
DBUG_PRINT("error", ("Can't read file header"));
DBUG_RETURN(LSN_ERROR);