Commit 8f717ed3 authored by sjaakola's avatar sjaakola Committed by Jan Lindström

refs MW-245 - allowing USE <database> with dirty reads configuration - fix for...

refs MW-245 - allowing USE <database> with dirty reads configuration - fix for logic of setting wsrep ready status
parent 2a729b5f
...@@ -275,6 +275,7 @@ void init_update_queries(void) ...@@ -275,6 +275,7 @@ void init_update_queries(void)
server_command_flags[COM_SHUTDOWN]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_SHUTDOWN]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_SLEEP]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_SLEEP]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_TIME]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_TIME]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_INIT_DB]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_END]= CF_SKIP_WSREP_CHECK; server_command_flags[COM_END]= CF_SKIP_WSREP_CHECK;
/* /*
...@@ -913,7 +914,8 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) ...@@ -913,7 +914,8 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables)
#ifdef WITH_WSREP #ifdef WITH_WSREP
static bool wsrep_node_is_ready(THD *thd) static bool wsrep_node_is_ready(THD *thd)
{ {
if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready) if (thd->variables.wsrep_on && !thd->wsrep_applier &&
(!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE))
{ {
my_message(ER_UNKNOWN_COM_ERROR, my_message(ER_UNKNOWN_COM_ERROR,
"WSREP has not yet prepared node for application use", "WSREP has not yet prepared node for application use",
...@@ -1104,8 +1106,9 @@ bool do_command(THD *thd) ...@@ -1104,8 +1106,9 @@ bool do_command(THD *thd)
/* /*
Bail out if DB snapshot has not been installed. Bail out if DB snapshot has not been installed.
*/ */
if (!(server_command_flags[command] & CF_SKIP_WSREP_CHECK) && if (thd->variables.wsrep_on && !thd->wsrep_applier &&
!wsrep_node_is_ready(thd)) (!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE) &&
(server_command_flags[command] & CF_SKIP_WSREP_CHECK) == 0)
{ {
thd->protocol->end_statement(); thd->protocol->end_statement();
...@@ -2674,17 +2677,16 @@ mysql_execute_command(THD *thd) ...@@ -2674,17 +2677,16 @@ mysql_execute_command(THD *thd)
} }
/* /*
Bail out if DB snapshot has not been installed. SET and SHOW commands, * Bail out if DB snapshot has not been installed. We however,
however, are always allowed. * allow SET and SHOW queries and reads from information schema
Select query is also allowed if it does not access any table. * and dirty reads (if configured)
We additionally allow all other commands that do not change data in
case wsrep_dirty_reads is enabled.
*/ */
if (thd->variables.wsrep_on && !thd->wsrep_applier && if (thd->variables.wsrep_on &&
!(wsrep_ready || !thd->wsrep_applier &&
(thd->variables.wsrep_dirty_reads && !(wsrep_ready && wsrep_reject_queries == WSREP_REJECT_NONE) &&
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) || !(thd->variables.wsrep_dirty_reads &&
wsrep_tables_accessible_when_detached(all_tables)) && (sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) &&
!wsrep_tables_accessible_when_detached(all_tables) &&
lex->sql_command != SQLCOM_SET_OPTION && lex->sql_command != SQLCOM_SET_OPTION &&
!wsrep_is_show_query(lex->sql_command)) !wsrep_is_show_query(lex->sql_command))
{ {
......
...@@ -389,15 +389,12 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type) ...@@ -389,15 +389,12 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
{ {
switch (wsrep_reject_queries) { switch (wsrep_reject_queries) {
case WSREP_REJECT_NONE: case WSREP_REJECT_NONE:
wsrep_ready_set(TRUE);
WSREP_INFO("Allowing client queries due to manual setting"); WSREP_INFO("Allowing client queries due to manual setting");
break; break;
case WSREP_REJECT_ALL: case WSREP_REJECT_ALL:
wsrep_ready_set(FALSE);
WSREP_INFO("Rejecting client queries due to manual setting"); WSREP_INFO("Rejecting client queries due to manual setting");
break; break;
case WSREP_REJECT_ALL_KILL: case WSREP_REJECT_ALL_KILL:
wsrep_ready_set(FALSE);
wsrep_close_client_connections(FALSE); wsrep_close_client_connections(FALSE);
WSREP_INFO("Rejecting client queries and killing connections due to manual setting"); WSREP_INFO("Rejecting client queries and killing connections due to manual setting");
break; break;
......
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