Commit 11afc5d4 authored by unknown's avatar unknown

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

into  mysql.com:/home/my/mysql-maria


include/my_sys.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
storage/maria/ma_checkpoint.c:
  Auto merged
storage/maria/ma_pagecache.c:
  Auto merged
storage/maria/ma_pagecache.h:
  Auto merged
storage/maria/maria_chk.c:
  Auto merged
storage/maria/ma_recovery.c:
  SCCS merged
parents ea6ec89e 2c6961ef
......@@ -90,6 +90,8 @@ extern int NEAR my_errno; /* Last error in mysys */
#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
#define ME_JUST_INFO 1024 /**< not error but just info */
#define ME_JUST_WARNING 2048 /**< not error but just warning */
/* Bits in last argument to fn_format */
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
......@@ -208,6 +210,7 @@ extern int errno; /* declare errno */
extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
extern char *home_dir; /* Home directory for user */
extern const char *my_progname; /* program-name (printed in errors) */
extern const char *my_progname_short; /* like above but without directory */
extern char NEAR curr_dir[]; /* Current directory for user */
extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
......
......@@ -4885,12 +4885,7 @@ sub gdb_arguments {
{
# write init file for mysqld
mtr_tofile($gdb_init_file,
"set args $str\n" .
"break mysql_parse\n" .
"commands 1\n" .
"disable 1\n" .
"end\n" .
"run");
"set args $str\n");
}
if ( $opt_manual_gdb )
......@@ -4950,11 +4945,7 @@ sub ddd_arguments {
# write init file for mysqld
mtr_tofile($gdb_init_file,
"file $$exe\n" .
"set args $str\n" .
"break mysql_parse\n" .
"commands 1\n" .
"disable 1\n" .
"end");
"set args $str\n");
}
if ( $opt_manual_ddd )
......
......@@ -78,6 +78,7 @@ my_bool my_init(void)
my_umask= 0660; /* Default umask for new files */
my_umask_dir= 0700; /* Default umask for new directories */
init_glob_errs();
my_progname_short= my_progname + dirname_length(my_progname);
#if defined(THREAD) && defined(SAFE_MUTEX)
safe_mutex_global_init(); /* Must be called early */
#endif
......
......@@ -26,7 +26,7 @@ my_bool timed_mutexes= 0;
/* from my_init */
char * home_dir=0;
const char *my_progname=0;
const char *my_progname= NULL, *my_progname_short= NULL;
char NEAR curr_dir[FN_REFLEN]= {0},
NEAR home_dir_buff[FN_REFLEN]= {0};
ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0;
......
......@@ -2558,6 +2558,8 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags);
int my_message_sql(uint error, const char *str, myf MyFlags)
{
THD *thd;
MYSQL_ERROR::enum_warning_level level;
sql_print_message_func func;
DBUG_ENTER("my_message_sql");
DBUG_PRINT("error", ("error: %u message: '%s'", error, str));
/*
......@@ -2565,21 +2567,36 @@ int my_message_sql(uint error, const char *str, myf MyFlags)
will be fixed
DBUG_ASSERT(error != 0);
*/
if (MyFlags & ME_JUST_INFO)
{
level= MYSQL_ERROR::WARN_LEVEL_NOTE;
func= sql_print_information;
}
else if (MyFlags & ME_JUST_WARNING)
{
level= MYSQL_ERROR::WARN_LEVEL_WARN;
func= sql_print_warning;
}
else
{
level= MYSQL_ERROR::WARN_LEVEL_ERROR;
func= sql_print_error;
}
if ((thd= current_thd))
{
/*
TODO: There are two exceptions mechanism (THD and sp_rcontext),
this could be improved by having a common stack of handlers.
*/
if (thd->handle_error(error,
MYSQL_ERROR::WARN_LEVEL_ERROR))
if (thd->handle_error(error, level) ||
(thd->spcont && thd->spcont->handle_error(error, level, thd)))
DBUG_RETURN(0);
if (thd->spcont &&
thd->spcont->handle_error(error, MYSQL_ERROR::WARN_LEVEL_ERROR, thd))
{
DBUG_RETURN(0);
}
if (level == MYSQL_ERROR::WARN_LEVEL_WARN)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, error, str);
if (level != MYSQL_ERROR::WARN_LEVEL_ERROR)
goto to_error_log;
thd->query_error= 1; // needed to catch query errors during replication
......@@ -2611,8 +2628,9 @@ int my_message_sql(uint error, const char *str, myf MyFlags)
}
}
}
to_error_log:
if (!thd || MyFlags & ME_NOREFRESH)
sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
(*func)("%s: %s", my_progname_short, str); /* purecov: inspected */
DBUG_RETURN(0);
}
......@@ -3262,6 +3280,9 @@ static int init_server_components()
}
}
/* set up the hook before initializing plugins which may use it */
error_handler_hook= my_message_sql;
if (xid_cache_init())
{
sql_print_error("Out of memory");
......@@ -3872,7 +3893,6 @@ we force server id to 2, but this MySQL server will not act as a slave.");
init signals & alarm
After this we can't quit by a simple unireg_abort
*/
error_handler_hook= my_message_sql;
start_signal_handler(); // Creates pidfile
if (mysql_rm_tmp_tables() || acl_init(opt_noacl) ||
......
This diff is collapsed.
......@@ -79,3 +79,14 @@ static inline LSN lsn_read_non_atomic_32(const volatile LSN *x)
}
#define lsn_read_non_atomic(x) lsn_read_non_atomic_32(&x)
#endif
/**
prints a message from a task not connected to any user (checkpoint
and recovery for example).
@param level 0 if error, ME_JUST_WARNING if warning,
ME_JUST_INFO if info
@param sentence text to write
*/
#define ma_message_no_user(level, sentence) \
my_printf_error(HA_ERR_GENERIC, "Maria engine: %s", MYF(level), sentence)
......@@ -3577,21 +3577,37 @@ static int cmp_sec_link(PAGECACHE_BLOCK_LINK **a, PAGECACHE_BLOCK_LINK **b)
}
/*
Flush a portion of changed blocks to disk,
free used blocks if requested
/**
@brief Flush a portion of changed blocks to disk, free used blocks
if requested
@param pagecache This page cache reference.
@param file File which should be flushed
@param cache Beginning of array of the block.
@param end Reference to the block after last in the array.
@param flush_type Type of the flush.
@param first_errno Where to store first errno of the flush.
@return Operation status
@retval PCFLUSH_OK OK
@retval PCFLUSH_ERROR There was errors during the flush process.
@retval PCFLUSH_PINNED Pinned blocks was met and skipped.
@retval PCFLUSH_PINNED_AND_ERROR PCFLUSH_ERROR and PCFLUSH_PINNED.
*/
static int flush_cached_blocks(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
PAGECACHE_BLOCK_LINK **cache,
PAGECACHE_BLOCK_LINK **end,
enum flush_type type)
enum flush_type type,
int *first_errno)
{
int rc= PCFLUSH_OK;
int error;
int last_errno= 0;
uint count= (uint) (end-cache);
DBUG_ENTER("flush_cached_blocks");
*first_errno= 0;
/* Don't lock the cache during the flush */
pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
......@@ -3616,7 +3632,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
PCBLOCK_INFO(block);
/* undo the mark put by flush_pagecache_blocks_int(): */
block->status&= ~PCBLOCK_IN_FLUSH;
last_errno= -1;
rc|= PCFLUSH_PINNED;
unreg_request(pagecache, block, 1);
continue;
}
......@@ -3657,8 +3673,8 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
if (error)
{
block->status|= PCBLOCK_ERROR;
if (!last_errno)
last_errno= errno ? errno : -1;
if (!*first_errno)
*first_errno= errno ? errno : -1;
}
#ifdef THREAD
/*
......@@ -3683,7 +3699,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
unreg_request(pagecache, block, 1);
}
}
DBUG_RETURN(last_errno);
DBUG_RETURN(rc);
}
......@@ -3711,8 +3727,10 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
this situation.
@return Operation status
@retval 0 OK
@retval 1 Error
@retval PCFLUSH_OK OK
@retval PCFLUSH_ERROR There was errors during the flush process.
@retval PCFLUSH_PINNED Pinned blocks was met and skipped.
@retval PCFLUSH_PINNED_AND_ERROR PCFLUSH_ERROR and PCFLUSH_PINNED.
*/
static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
......@@ -3723,6 +3741,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
{
PAGECACHE_BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache;
int last_errno= 0;
int rc= PCFLUSH_OK;
DBUG_ENTER("flush_pagecache_blocks_int");
DBUG_PRINT("enter",
("file: %d blocks_used: %lu blocks_changed: %lu type: %d",
......@@ -3885,8 +3904,9 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
This happens only if there is not enough
memory for the big block
*/
if ((error= flush_cached_blocks(pagecache, file, cache,
end,type)))
if ((rc|= flush_cached_blocks(pagecache, file, cache,
end, type, &error)) &
PCFLUSH_ERROR)
last_errno=error;
DBUG_PRINT("info", ("restarting..."));
/*
......@@ -3920,7 +3940,8 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
}
if (pos != cache)
{
if ((error= flush_cached_blocks(pagecache, file, cache, pos, type)))
if ((rc|= flush_cached_blocks(pagecache, file, cache, pos, type,
&error)) & PCFLUSH_ERROR)
last_errno= error;
}
/* Wait until list of blocks in switch is empty */
......@@ -3998,8 +4019,8 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
if (cache != cache_buff)
my_free((uchar*) cache, MYF(0));
if (last_errno)
errno=last_errno; /* Return first error */
DBUG_RETURN(last_errno != 0);
errno= last_errno; /* Return first error */
DBUG_RETURN(rc);
}
......@@ -4016,8 +4037,10 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
the block will be passed too.
@return Operation status
@retval 0 OK
@retval 1 Error
@retval PCFLUSH_OK OK
@retval PCFLUSH_ERROR There was errors during the flush process.
@retval PCFLUSH_PINNED Pinned blocks was met and skipped.
@retval PCFLUSH_PINNED_AND_ERROR PCFLUSH_ERROR and PCFLUSH_PINNED.
*/
int flush_pagecache_blocks_with_filter(PAGECACHE *pagecache,
......
......@@ -246,6 +246,20 @@ extern void pagecache_unpin(PAGECACHE *pagecache,
extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_BLOCK_LINK *link,
LSN lsn);
/* Results of flush operation (bit field in fact) */
/* The flush is done. */
#define PCFLUSH_OK 0
/* There was errors during the flush process. */
#define PCFLUSH_ERROR 1
/* Pinned blocks was met and skipped. */
#define PCFLUSH_PINNED 2
/* PCFLUSH_ERROR and PCFLUSH_PINNED. */
#define PCFLUSH_PINNED_AND_ERROR (PCFLUSH_ERROR|PCFLUSH_PINNED)
#define flush_pagecache_blocks(A,B,C) \
flush_pagecache_blocks_with_filter(A,B,C,NULL,NULL)
extern int flush_pagecache_blocks_with_filter(PAGECACHE *keycache,
......
......@@ -59,7 +59,6 @@ static my_bool skip_DDLs; /**< if REDO phase should skip DDL records */
/** @brief to avoid writing a checkpoint if recovery did nothing. */
static my_bool checkpoint_useful;
static ulonglong now; /**< for tracking execution time of phases */
static char preamble[]= "Maria engine: starting recovery; ";
uint warnings; /**< count of warnings */
#define prototype_redo_exec_hook(R) \
......@@ -163,6 +162,11 @@ void tprint(FILE *trace_file __attribute__ ((unused)),
#define ALERT_USER() DBUG_ASSERT(0)
static void print_preamble()
{
ma_message_no_user(ME_JUST_INFO, "starting recovery");
}
/**
@brief Recovers from the last checkpoint.
......@@ -304,7 +308,10 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply,
if (recovery_message_printed == REC_MSG_REDO)
{
float phase_took= (now - old_now)/10000000.0;
/** @todo RECOVERY BUG all prints to stderr should go to error log */
/*
Detailed progress info goes to stderr, because ma_message_no_user()
cannot put several messages on one line.
*/
fprintf(stderr, " (%.1f seconds); ", phase_took);
}
......@@ -346,7 +353,6 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply,
if (recovery_message_printed == REC_MSG_UNDO)
{
float phase_took= (now - old_now)/10000000.0;
/** @todo RECOVERY BUG all prints to stderr should go to error log */
fprintf(stderr, " (%.1f seconds); ", phase_took);
}
......@@ -362,7 +368,6 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply,
if (recovery_message_printed == REC_MSG_FLUSH)
{
float phase_took= (now - old_now)/10000000.0;
/** @todo RECOVERY BUG all prints to stderr should go to error log */
fprintf(stderr, " (%.1f seconds); ", phase_took);
}
......@@ -393,8 +398,11 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply,
*warnings_count= warnings;
if (recovery_message_printed != REC_MSG_NONE)
{
/** @todo RECOVERY BUG all prints to stderr should go to error log */
fprintf(stderr, "%s.\n", error ? " failed" : "done");
fprintf(stderr, "\n");
if (error)
ma_message_no_user(0, "recovery failed");
else
ma_message_no_user(ME_JUST_INFO, "recovery done");
}
/* we don't cleanly close tables if we hit some error (may corrupt them) */
DBUG_RETURN(error);
......@@ -2180,10 +2188,7 @@ static int run_redo_phase(LSN lsn, enum maria_apply_log_way apply)
translog_destroy_scanner(&scanner);
translog_free_record_header(&rec);
if (recovery_message_printed == REC_MSG_REDO)
{
/** @todo RECOVERY BUG all prints to stderr should go to error log */
fprintf(stderr, " 100%%");
}
return 0;
err:
......@@ -2286,8 +2291,7 @@ static int run_undo_phase(uint unfinished)
if (tracef != stdout)
{
if (recovery_message_printed == REC_MSG_NONE)
fprintf(stderr, preamble);
/** @todo RECOVERY BUG all prints to stderr should go to error log */
print_preamble();
fprintf(stderr, "transactions to roll back:");
recovery_message_printed= REC_MSG_UNDO;
}
......@@ -2659,10 +2663,9 @@ static int close_all_tables(void)
if (tracef != stdout)
{
if (recovery_message_printed == REC_MSG_NONE)
fprintf(stderr, preamble);
print_preamble();
for (count= 0, list_element= maria_open_list ;
list_element ; count++, (list_element= list_element->next))
/** @todo RECOVERY BUG all prints to stderr should go to error log */
fprintf(stderr, "tables to flush:");
recovery_message_printed= REC_MSG_FLUSH;
}
......@@ -2772,8 +2775,7 @@ static void print_redo_phase_progress(TRANSLOG_ADDRESS addr)
return;
if (recovery_message_printed == REC_MSG_NONE)
{
/** @todo RECOVERY BUG all prints to stderr should go to error log */
fprintf(stderr, preamble);
print_preamble();
fprintf(stderr, "recovered pages: 0%%");
recovery_message_printed= REC_MSG_REDO;
}
......
......@@ -39,7 +39,6 @@ static char **default_argv;
static const char *load_default_groups[]= { "maria_chk", 0 };
static const char *set_collation_name, *opt_tmpdir;
static CHARSET_INFO *set_collation;
static const char *my_progname_short;
static int stopwords_inited= 0;
static MY_TMPDIR maria_chk_tmpdir;
......@@ -93,7 +92,6 @@ int main(int argc, char **argv)
{
int error;
MY_INIT(argv[0]);
my_progname_short= my_progname+dirname_length(my_progname);
maria_chk_init(&check_param);
check_param.opt_lock_memory= 1; /* Lock memory if possible */
......
......@@ -32,7 +32,6 @@ const char *default_dbug_option= "d:t:i:o,/tmp/maria_read_log.trace";
static my_bool opt_only_display, opt_apply, opt_apply_undo, opt_silent,
opt_check;
static ulong opt_page_buffer_size;
static const char *my_progname_short;
int main(int argc, char **argv)
{
......@@ -40,7 +39,6 @@ int main(int argc, char **argv)
char **default_argv;
uint warnings_count;
MY_INIT(argv[0]);
my_progname_short= my_progname+dirname_length(my_progname);
load_defaults("my", load_default_groups, &argc, &argv);
default_argv= argv;
......
......@@ -40,7 +40,6 @@ static const char *set_collation_name, *opt_tmpdir;
static CHARSET_INFO *set_collation;
static long opt_myisam_block_size;
static long opt_key_cache_block_size;
static const char *my_progname_short;
static int stopwords_inited= 0;
static MY_TMPDIR myisamchk_tmpdir;
......@@ -85,7 +84,6 @@ int main(int argc, char **argv)
{
int error;
MY_INIT(argv[0]);
my_progname_short= my_progname+dirname_length(my_progname);
myisamchk_init(&check_param);
check_param.opt_lock_memory=1; /* Lock memory if possible */
......
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