Skip to content

Commit

Permalink
refs MW-245 - allowing USE <database> with dirty reads configuration …
Browse files Browse the repository at this point in the history
…- fix for logic of setting wsrep ready status
  • Loading branch information
sjaakola authored and Jan Lindström committed Mar 20, 2018
1 parent 2a729b5 commit 8f717ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
34 changes: 18 additions & 16 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ void init_update_queries(void)
server_command_flags[COM_SHUTDOWN]= 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_INIT_DB]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_END]= CF_SKIP_WSREP_CHECK;

/*
Expand Down Expand Up @@ -913,7 +914,8 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables)
#ifdef WITH_WSREP
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,
"WSREP has not yet prepared node for application use",
Expand Down Expand Up @@ -1104,8 +1106,9 @@ bool do_command(THD *thd)
/*
Bail out if DB snapshot has not been installed.
*/
if (!(server_command_flags[command] & CF_SKIP_WSREP_CHECK) &&
!wsrep_node_is_ready(thd))
if (thd->variables.wsrep_on && !thd->wsrep_applier &&
(!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE) &&
(server_command_flags[command] & CF_SKIP_WSREP_CHECK) == 0)
{
thd->protocol->end_statement();

Expand Down Expand Up @@ -2674,19 +2677,18 @@ mysql_execute_command(THD *thd)
}

/*
Bail out if DB snapshot has not been installed. SET and SHOW commands,
however, are always allowed.
Select query is also allowed if it does not access any table.
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 &&
!(wsrep_ready ||
(thd->variables.wsrep_dirty_reads &&
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) ||
wsrep_tables_accessible_when_detached(all_tables)) &&
lex->sql_command != SQLCOM_SET_OPTION &&
!wsrep_is_show_query(lex->sql_command))
* Bail out if DB snapshot has not been installed. We however,
* allow SET and SHOW queries and reads from information schema
* and dirty reads (if configured)
*/
if (thd->variables.wsrep_on &&
!thd->wsrep_applier &&
!(wsrep_ready && wsrep_reject_queries == WSREP_REJECT_NONE) &&
!(thd->variables.wsrep_dirty_reads &&
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) &&
!wsrep_tables_accessible_when_detached(all_tables) &&
lex->sql_command != SQLCOM_SET_OPTION &&
!wsrep_is_show_query(lex->sql_command))
{
my_message(ER_UNKNOWN_COM_ERROR,
"WSREP has not yet prepared node for application use", MYF(0));
Expand Down
3 changes: 0 additions & 3 deletions sql/wsrep_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,12 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
{
switch (wsrep_reject_queries) {
case WSREP_REJECT_NONE:
wsrep_ready_set(TRUE);
WSREP_INFO("Allowing client queries due to manual setting");
break;
case WSREP_REJECT_ALL:
wsrep_ready_set(FALSE);
WSREP_INFO("Rejecting client queries due to manual setting");
break;
case WSREP_REJECT_ALL_KILL:
wsrep_ready_set(FALSE);
wsrep_close_client_connections(FALSE);
WSREP_INFO("Rejecting client queries and killing connections due to manual setting");
break;
Expand Down

0 comments on commit 8f717ed

Please sign in to comment.