diff options
-rw-r--r-- | include/my_dbug.h | 2 | ||||
-rw-r--r-- | mysys/my_thr_init.c | 15 | ||||
-rw-r--r-- | sql/handler.cc | 10 | ||||
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/mysql_priv.h | 4 | ||||
-rw-r--r-- | storage/maria/ha_maria.cc | 3 | ||||
-rw-r--r-- | storage/maria/ma_blockrec.c | 6 | ||||
-rw-r--r-- | storage/maria/ma_check.c | 9 | ||||
-rw-r--r-- | storage/maria/ma_checkpoint.c | 6 | ||||
-rw-r--r-- | storage/maria/ma_control_file.c | 26 | ||||
-rw-r--r-- | storage/maria/ma_loghandler.c | 11 | ||||
-rw-r--r-- | storage/maria/ma_pagecache.c | 5 |
12 files changed, 68 insertions, 31 deletions
diff --git a/include/my_dbug.h b/include/my_dbug.h index bce22668eed..a9611b05f0a 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -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 } 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 421708e5958..17b6e943f17 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 ac8831495f5..c027c9343a1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -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); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3f83d577707..0d1ffcc4fa2 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 ff8db50bfce..f7085f96aa5 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -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; } diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 369f697bc83..21c0683fd0c 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 efde12d36a2..89426784df0 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..ecc199dd057 100644 --- a/storage/maria/ma_control_file.c +++ b/storage/maria/ma_control_file.c @@ -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)); /* diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index a1d907f07fa..cd6bbab6d0c 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -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); diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index 64109dd7d27..91c2ddfcb5d 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -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) |