MDEV-17068 mysql system table is marked as crashed and should be repaired after the server crashes or is killed
- Changed ERROR to WARNING for MyISAM/Aria message that are warnings in the check utilities. This affects for example "client is using or hasn't closed the table properly". - Print "Table is fixed" if check succeded in fixing the table.
This commit is contained in:
parent
f451fd8c06
commit
8cc53aded9
@ -500,7 +500,8 @@ call mtr.add_suppression("Checking table");
|
||||
insert delayed into t1 values (2,2);
|
||||
Warnings:
|
||||
Error 145 Table './test/t1' is marked as crashed and should be repaired
|
||||
Error 1034 1 client is using or hasn't closed the table properly
|
||||
Warning 1034 1 client is using or hasn't closed the table properly
|
||||
Note 1034 Table is fixed
|
||||
insert delayed into t1 values (3,3);
|
||||
flush tables t1;
|
||||
select * from t1;
|
||||
|
@ -2545,7 +2545,7 @@ INSERT INTO t1 VALUES
|
||||
('0'),('0'),('0'),('0'),('0'),('0'),('0');
|
||||
Warnings:
|
||||
Error 1034 myisam_sort_buffer_size is too small. X
|
||||
Error 1034 Number of rows changed from 0 to 157
|
||||
Warning 1034 Number of rows changed from 0 to 157
|
||||
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
|
||||
INSERT INTO t1 VALUES('1');
|
||||
SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1;
|
||||
|
@ -87,7 +87,7 @@ a
|
||||
6
|
||||
Warnings:
|
||||
Error 145 Table 't1' is marked as crashed and should be repaired
|
||||
Error 1034 Number of rows changed from 3 to 6
|
||||
Warning 1034 Number of rows changed from 3 to 6
|
||||
#
|
||||
# Cleanup
|
||||
#
|
||||
@ -139,7 +139,7 @@ a
|
||||
4
|
||||
Warnings:
|
||||
Error 145 Table 't1' is marked as crashed and should be repaired
|
||||
Error 1034 Number of rows changed from 1 to 2
|
||||
Warning 1034 Number of rows changed from 1 to 2
|
||||
connect con2, localhost, root;
|
||||
ALTER TABLE t2 ADD val INT;
|
||||
connection default;
|
||||
|
@ -78,7 +78,7 @@ INSERT INTO t1 VALUES
|
||||
('0'),('0'),('0'),('0'),('0'),('0'),('0');
|
||||
Warnings:
|
||||
Error 1034 myisam_sort_buffer_size is too small. X
|
||||
Error 1034 Number of rows changed from 0 to 157
|
||||
Warning 1034 Number of rows changed from 0 to 157
|
||||
SET myisam_repair_threads=2;
|
||||
REPAIR TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
|
@ -27,7 +27,7 @@ ThursdayMorningsMarket
|
||||
ThursdayMorningsMarketb
|
||||
Warnings:
|
||||
Error 145 t_corrupted2' is marked as crashed and should be repaired
|
||||
Error 1034 1 client is using or hasn't closed the table properly
|
||||
Warning 1034 1 client is using or hasn't closed the table properly
|
||||
Error 1034 Wrong base information on indexpage at page: 1
|
||||
select * from t_corrupted2;
|
||||
a
|
||||
|
@ -18,10 +18,10 @@ a
|
||||
11
|
||||
Warnings:
|
||||
Error 145 Table 't1_will_crash' is marked as crashed and should be repaired
|
||||
Error 1034 1 client is using or hasn't closed the table properly
|
||||
Warning 1034 1 client is using or hasn't closed the table properly
|
||||
Error 1034 Size of indexfile is: 1024 Should be: 2048
|
||||
Error 1034 Size of datafile is: 77 Should be: 7
|
||||
Error 1034 Number of rows changed from 1 to 11
|
||||
Warning 1034 Size of datafile is: 77 Should be: 7
|
||||
Warning 1034 Number of rows changed from 1 to 11
|
||||
DROP TABLE t1_will_crash;
|
||||
CREATE TABLE t1_will_crash (a INT, KEY (a))
|
||||
ENGINE=MyISAM
|
||||
@ -47,8 +47,8 @@ a
|
||||
11
|
||||
Warnings:
|
||||
Error 145 Table 't1_will_crash#P#p1' is marked as crashed and should be repaired
|
||||
Error 1034 1 client is using or hasn't closed the table properly
|
||||
Warning 1034 1 client is using or hasn't closed the table properly
|
||||
Error 1034 Size of indexfile is: 1024 Should be: 2048
|
||||
Error 1034 Size of datafile is: 28 Should be: 7
|
||||
Error 1034 Number of rows changed from 1 to 4
|
||||
Warning 1034 Size of datafile is: 28 Should be: 7
|
||||
Warning 1034 Number of rows changed from 1 to 4
|
||||
DROP TABLE t1_will_crash;
|
||||
|
@ -1162,6 +1162,10 @@ bool LOGGER::error_log_print(enum loglevel level, const char *format,
|
||||
{
|
||||
bool error= FALSE;
|
||||
Log_event_handler **current_handler;
|
||||
THD *thd= current_thd;
|
||||
|
||||
if (likely(thd))
|
||||
thd->error_printed_to_log= 1;
|
||||
|
||||
/* currently we don't need locking here as there is no error_log table */
|
||||
for (current_handler= error_log_handler_list ; *current_handler ;)
|
||||
|
@ -3123,6 +3123,9 @@ public:
|
||||
it returned an error on master, and this is OK on the slave.
|
||||
*/
|
||||
bool is_slave_error;
|
||||
/* True if we have printed something to the error log for this statement */
|
||||
bool error_printed_to_log;
|
||||
|
||||
/*
|
||||
True when a transaction is queued up for binlog group commit.
|
||||
Used so that if another transaction needs to wait for a row lock held by
|
||||
|
@ -7593,8 +7593,14 @@ void THD::reset_for_next_command(bool do_clear_error)
|
||||
DBUG_ASSERT(!in_sub_stmt);
|
||||
|
||||
if (likely(do_clear_error))
|
||||
{
|
||||
clear_error(1);
|
||||
|
||||
/*
|
||||
The following variable can't be reset in clear_error() as
|
||||
clear_error() is called during auto_repair of table
|
||||
*/
|
||||
error_printed_to_log= 0;
|
||||
}
|
||||
free_list= 0;
|
||||
/*
|
||||
We also assign stmt_lex in lex_start(), but during bootstrap this
|
||||
|
@ -387,6 +387,10 @@ static void init_aria_psi_keys(void)
|
||||
#define init_aria_psi_keys() /* no-op */
|
||||
#endif /* HAVE_PSI_INTERFACE */
|
||||
|
||||
const char *MA_CHECK_INFO= "info";
|
||||
const char *MA_CHECK_WARNING= "warning";
|
||||
const char *MA_CHECK_ERROR= "error";
|
||||
|
||||
/*****************************************************************************
|
||||
** MARIA tables
|
||||
*****************************************************************************/
|
||||
@ -399,6 +403,20 @@ static handler *maria_create_handler(handlerton *hton,
|
||||
}
|
||||
|
||||
|
||||
static void _ma_check_print(HA_CHECK *param, const char* msg_type,
|
||||
const char *msgbuf)
|
||||
{
|
||||
if (msg_type == MA_CHECK_INFO)
|
||||
sql_print_information("%s.%s: %s", param->db_name, param->table_name,
|
||||
msgbuf);
|
||||
else if (msg_type == MA_CHECK_WARNING)
|
||||
sql_print_warning("%s.%s: %s", param->db_name, param->table_name,
|
||||
msgbuf);
|
||||
else
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
}
|
||||
|
||||
|
||||
// collect errors printed by maria_check routines
|
||||
|
||||
static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
|
||||
@ -420,16 +438,21 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
|
||||
|
||||
if (!thd->vio_ok())
|
||||
{
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
_ma_check_print(param, msg_type, msgbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (param->testflag &
|
||||
(T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))
|
||||
{
|
||||
my_message(ER_NOT_KEYFILE, msgbuf, MYF(0));
|
||||
myf flag= 0;
|
||||
if (msg_type == MA_CHECK_INFO)
|
||||
flag= ME_NOTE;
|
||||
else if (msg_type == MA_CHECK_WARNING)
|
||||
flag= ME_WARNING;
|
||||
my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag));
|
||||
if (thd->variables.log_warnings > 2)
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
_ma_check_print(param, msg_type, msgbuf);
|
||||
return;
|
||||
}
|
||||
length= (uint) (strxmov(name, param->db_name, ".", param->table_name,
|
||||
@ -451,7 +474,7 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
|
||||
sql_print_error("Failed on my_net_write, writing to stderr instead: %s.%s: %s\n",
|
||||
param->db_name, param->table_name, msgbuf);
|
||||
else if (thd->variables.log_warnings > 2)
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
_ma_check_print(param, msg_type, msgbuf);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -879,7 +902,7 @@ void _ma_check_print_error(HA_CHECK *param, const char *fmt, ...)
|
||||
if (param->testflag & T_SUPPRESS_ERR_HANDLING)
|
||||
DBUG_VOID_RETURN;
|
||||
va_start(args, fmt);
|
||||
_ma_check_print_msg(param, "error", fmt, args);
|
||||
_ma_check_print_msg(param, MA_CHECK_ERROR, fmt, args);
|
||||
va_end(args);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -890,7 +913,7 @@ void _ma_check_print_info(HA_CHECK *param, const char *fmt, ...)
|
||||
va_list args;
|
||||
DBUG_ENTER("_ma_check_print_info");
|
||||
va_start(args, fmt);
|
||||
_ma_check_print_msg(param, "info", fmt, args);
|
||||
_ma_check_print_msg(param, MA_CHECK_INFO, fmt, args);
|
||||
va_end(args);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -903,7 +926,7 @@ void _ma_check_print_warning(HA_CHECK *param, const char *fmt, ...)
|
||||
param->warning_printed= 1;
|
||||
param->out_flag |= O_DATA_LOST;
|
||||
va_start(args, fmt);
|
||||
_ma_check_print_msg(param, "warning", fmt, args);
|
||||
_ma_check_print_msg(param, MA_CHECK_WARNING, fmt, args);
|
||||
va_end(args);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@ -1390,6 +1413,16 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
|
||||
mysql_mutex_unlock(&share->intern_lock);
|
||||
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
|
||||
HA_STATUS_CONST);
|
||||
|
||||
/*
|
||||
Write a 'table is ok' message to error log if table is ok and
|
||||
we have written to error log that table was getting checked
|
||||
*/
|
||||
if (!error && !(table->db_stat & HA_READ_ONLY) &&
|
||||
!maria_is_crashed(file) && thd->error_printed_to_log &&
|
||||
(param->warning_printed || param->error_printed ||
|
||||
param->note_printed))
|
||||
_ma_check_print_info(param, "Table is fixed");
|
||||
}
|
||||
}
|
||||
else if (!maria_is_crashed(file) && !thd->killed)
|
||||
|
@ -96,6 +96,10 @@ static MYSQL_THDVAR_ENUM(stats_method, PLUGIN_VAR_RQCMDARG,
|
||||
"and NULLS_IGNORED", NULL, NULL,
|
||||
MI_STATS_METHOD_NULLS_NOT_EQUAL, &myisam_stats_method_typelib);
|
||||
|
||||
const char *MI_CHECK_INFO= "info";
|
||||
const char *MI_CHECK_WARNING= "warning";
|
||||
const char *MI_CHECK_ERROR= "error";
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
/**
|
||||
Causes the thread to wait in a spin lock for a query kill signal.
|
||||
@ -130,6 +134,20 @@ static handler *myisam_create_handler(handlerton *hton,
|
||||
return new (mem_root) ha_myisam(hton, table);
|
||||
}
|
||||
|
||||
|
||||
static void mi_check_print(HA_CHECK *param, const char* msg_type,
|
||||
const char *msgbuf)
|
||||
{
|
||||
if (msg_type == MI_CHECK_INFO)
|
||||
sql_print_information("%s.%s: %s", param->db_name, param->table_name,
|
||||
msgbuf);
|
||||
else if (msg_type == MI_CHECK_WARNING)
|
||||
sql_print_warning("%s.%s: %s", param->db_name, param->table_name,
|
||||
msgbuf);
|
||||
else
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
}
|
||||
|
||||
// collect errors printed by mi_check routines
|
||||
|
||||
static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
|
||||
@ -151,16 +169,21 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
|
||||
|
||||
if (!thd->vio_ok())
|
||||
{
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
mi_check_print(param, msg_type, msgbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR |
|
||||
T_AUTO_REPAIR))
|
||||
{
|
||||
my_message(ER_NOT_KEYFILE, msgbuf, MYF(0));
|
||||
myf flag= 0;
|
||||
if (msg_type == MI_CHECK_INFO)
|
||||
flag= ME_NOTE;
|
||||
else if (msg_type == MI_CHECK_WARNING)
|
||||
flag= ME_WARNING;
|
||||
my_message(ER_NOT_KEYFILE, msgbuf, MYF(flag));
|
||||
if (thd->variables.log_warnings > 2 && ! thd->log_all_errors)
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
mi_check_print(param, msg_type, msgbuf);
|
||||
return;
|
||||
}
|
||||
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
|
||||
@ -185,7 +208,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
|
||||
sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
|
||||
msgbuf);
|
||||
else if (thd->variables.log_warnings > 2)
|
||||
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
|
||||
mi_check_print(param, msg_type, msgbuf);
|
||||
|
||||
if (param->need_print_msg_lock)
|
||||
mysql_mutex_unlock(¶m->print_msg_mutex);
|
||||
@ -592,7 +615,7 @@ void mi_check_print_error(HA_CHECK *param, const char *fmt,...)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
mi_check_print_msg(param, "error", fmt, args);
|
||||
mi_check_print_msg(param, MI_CHECK_ERROR, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -600,7 +623,7 @@ void mi_check_print_info(HA_CHECK *param, const char *fmt,...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
mi_check_print_msg(param, "info", fmt, args);
|
||||
mi_check_print_msg(param, MI_CHECK_INFO, fmt, args);
|
||||
param->note_printed= 1;
|
||||
va_end(args);
|
||||
}
|
||||
@ -611,7 +634,7 @@ void mi_check_print_warning(HA_CHECK *param, const char *fmt,...)
|
||||
param->out_flag|= O_DATA_LOST;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
mi_check_print_msg(param, "warning", fmt, args);
|
||||
mi_check_print_msg(param, MI_CHECK_WARNING, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -1036,6 +1059,15 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
mysql_mutex_unlock(&share->intern_lock);
|
||||
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
|
||||
HA_STATUS_CONST);
|
||||
/*
|
||||
Write a 'table is ok' message to error log if table is ok and
|
||||
we have written to error log that table was getting checked
|
||||
*/
|
||||
if (!error && !(table->db_stat & HA_READ_ONLY) &&
|
||||
!mi_is_crashed(file) && thd->error_printed_to_log &&
|
||||
(param->warning_printed || param->error_printed ||
|
||||
param->note_printed))
|
||||
mi_check_print_info(param, "Table is fixed");
|
||||
}
|
||||
}
|
||||
else if (!mi_is_crashed(file) && !thd->killed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user