Commit c04dd359 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-maria

into  janus.mylan:/usr/home/serg/Abk/mysql-maria


sql/handler.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
include/my_dbug.h:
  merged
parents 7b59b82f 3e9e629c
......@@ -86,6 +86,7 @@ extern FILE *_db_fp_(void);
#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)
......@@ -115,6 +116,7 @@ extern FILE *_db_fp_(void);
#define DEBUGGER_OFF do { } while(0)
#define DEBUGGER_ON do { } while(0)
#define IF_DBUG(A)
#define DBUG_ABORT() abort()
#endif
#ifdef __cplusplus
}
......
......@@ -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);
......
......@@ -4099,7 +4099,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
......
......@@ -1678,8 +1678,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)
{
......
......@@ -235,7 +235,14 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
DBUG_RETURN(CONTROL_FILE_UNKNOWN_ERROR);
if (my_access(name,F_OK))
DBUG_RETURN(create_control_file(name, open_flags));
{
if (create_control_file(name, open_flags))
{
errmsg= "Can't create file";
goto err;
}
goto lock_file;
}
/* Otherwise, file exists */
......@@ -348,13 +355,23 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
CF_LSN_OFFSET);
last_logno= uint4korr(buffer + new_cf_create_time_size + CF_FILENO_OFFSET);
lock_file:
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)))
{
......@@ -365,11 +382,12 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
name, my_errno, MARIA_MAX_CONTROL_FILE_LOCK_RETRY);
if (retry++ > MARIA_MAX_CONTROL_FILE_LOCK_RETRY)
{
errmsg= "Could not get an exclusive lock; File is probably in use by another process";
errmsg= "Could not get an exclusive lock; file is probably in use by another process";
goto err;
}
sleep(1);
}
#endif
DBUG_RETURN(0);
......@@ -487,8 +505,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));
/*
......
......@@ -1316,9 +1316,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);
......
......@@ -1553,6 +1553,7 @@ static void unlink_hash(PAGECACHE *pagecache, PAGECACHE_HASH_LINK *hash_link)
struct st_my_thread_var *thread;
hash_link->file= first_page->file;
DBUG_ASSERT(first_page->pageno < ((ULL(1)) << 40));
hash_link->pageno= first_page->pageno;
do
{
......@@ -1714,6 +1715,7 @@ restart:
goto restart;
}
hash_link->file= *file;
DBUG_ASSERT(pageno < ((ULL(1)) << 40));
hash_link->pageno= pageno;
link_hash(start, hash_link);
/* Register the request for the page */
......@@ -2971,6 +2973,7 @@ uchar *pagecache_read(PAGECACHE *pagecache,
page_cache_page_pin_str[pin]));
DBUG_ASSERT(buff != 0 || (buff == 0 && (pin == PAGECACHE_PIN ||
pin == PAGECACHE_PIN_LEFT_PINNED)));
DBUG_ASSERT(pageno < ((ULL(1)) << 40));
#endif
if (!page_link)
......@@ -3302,6 +3305,7 @@ my_bool pagecache_delete(PAGECACHE *pagecache,
pin == PAGECACHE_PIN_LEFT_PINNED);
restart:
DBUG_ASSERT(pageno < ((ULL(1)) << 40));
if (pagecache->can_be_used)
{
/* Key cache is used */
......@@ -3476,6 +3480,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
DBUG_ASSERT(lock != PAGECACHE_LOCK_LEFT_READLOCKED);
DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK);
DBUG_ASSERT(offset + size <= pagecache->block_size);
DBUG_ASSERT(pageno < ((ULL(1)) << 40));
#endif
if (!page_link)
......
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