Bug#33982 debug assertion and crash reloading grant tables after sighup or kill

In certain rare cases when a process was interrupted
during a FLUSH PRIVILEGES operation the diagnostic
area would be set to an error state but the function
responsible for the operation would still signal
success. This would lead to a debug assertion error
later on when the server would attempt to reset the
DA before sending the error message.

This patch fixes the issue by assuring that
reload_acl_and_cache() always fails if an error
condition is raised.

The second issue was that a KILL could cause
a console error message which referred to a DA
state without first making sure that such a
state existed.

This patch fixes this issue in two different
palces by first checking DA state before
fetching the error message.

 

sql/sql_acl.cc:
  * Make sure that there is an error to print before attempting to do so.
  * Minor style change: change 1 to TRUE for clarity.
sql/sql_parse.cc:
  * Always fail reload_acl_and_cache() if the query was killed.
sql/sql_servers.cc:
  * Make sure that there is an error to print before attempting to do so.
This commit is contained in:
Kristofer Pettersson 2010-01-13 12:39:00 +01:00
parent be397eb400
commit b3dd4d9486
3 changed files with 24 additions and 10 deletions

View File

@ -310,7 +310,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
{ {
TABLE *table; TABLE *table;
READ_RECORD read_record_info; READ_RECORD read_record_info;
my_bool return_val= 1; my_bool return_val= TRUE;
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
char tmp_name[NAME_LEN+1]; char tmp_name[NAME_LEN+1];
int password_length; int password_length;
@ -623,7 +623,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
init_check_host(); init_check_host();
initialized=1; initialized=1;
return_val=0; return_val= FALSE;
end: end:
thd->variables.sql_mode= old_sql_mode; thd->variables.sql_mode= old_sql_mode;
@ -674,7 +674,7 @@ my_bool acl_reload(THD *thd)
DYNAMIC_ARRAY old_acl_hosts,old_acl_users,old_acl_dbs; DYNAMIC_ARRAY old_acl_hosts,old_acl_users,old_acl_dbs;
MEM_ROOT old_mem; MEM_ROOT old_mem;
bool old_initialized; bool old_initialized;
my_bool return_val= 1; my_bool return_val= TRUE;
DBUG_ENTER("acl_reload"); DBUG_ENTER("acl_reload");
if (thd->locked_tables) if (thd->locked_tables)
@ -701,6 +701,11 @@ my_bool acl_reload(THD *thd)
if (simple_open_n_lock_tables(thd, tables)) if (simple_open_n_lock_tables(thd, tables))
{ {
/*
Execution might have been interrupted; only print the error message
if an error condition has been raised.
*/
if (thd->main_da.is_error())
sql_print_error("Fatal error: Can't open and lock privilege tables: %s", sql_print_error("Fatal error: Can't open and lock privilege tables: %s",
thd->main_da.message()); thd->main_da.message());
goto end; goto end;

View File

@ -6949,7 +6949,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
if (options & REFRESH_USER_RESOURCES) if (options & REFRESH_USER_RESOURCES)
reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */ reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */
*write_to_binlog= tmp_write_to_binlog; *write_to_binlog= tmp_write_to_binlog;
return result; /*
If the query was killed then this function must fail.
*/
return result || thd->killed;
} }

View File

@ -241,8 +241,14 @@ bool servers_reload(THD *thd)
if (simple_open_n_lock_tables(thd, tables)) if (simple_open_n_lock_tables(thd, tables))
{ {
/*
Execution might have been interrupted; only print the error message
if an error condition has been raised.
*/
if (thd->main_da.is_error())
sql_print_error("Can't open and lock privilege tables: %s", sql_print_error("Can't open and lock privilege tables: %s",
thd->main_da.message()); thd->main_da.message());
return_val= FALSE;
goto end; goto end;
} }