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.
This commit is contained in:
parent
211a9e72a9
commit
7300af848a
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -350,11 +350,20 @@ 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));
|
||||
/*
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user