Skip to content

Commit 8f717ed

Browse files
sjaakolaJan Lindström
authored andcommitted
refs MW-245 - allowing USE <database> with dirty reads configuration - fix for logic of setting wsrep ready status
1 parent 2a729b5 commit 8f717ed

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

sql/sql_parse.cc

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ void init_update_queries(void)
275275
server_command_flags[COM_SHUTDOWN]= CF_SKIP_WSREP_CHECK;
276276
server_command_flags[COM_SLEEP]= CF_SKIP_WSREP_CHECK;
277277
server_command_flags[COM_TIME]= CF_SKIP_WSREP_CHECK;
278+
server_command_flags[COM_INIT_DB]= CF_SKIP_WSREP_CHECK;
278279
server_command_flags[COM_END]= CF_SKIP_WSREP_CHECK;
279280

280281
/*
@@ -913,7 +914,8 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables)
913914
#ifdef WITH_WSREP
914915
static bool wsrep_node_is_ready(THD *thd)
915916
{
916-
if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready)
917+
if (thd->variables.wsrep_on && !thd->wsrep_applier &&
918+
(!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE))
917919
{
918920
my_message(ER_UNKNOWN_COM_ERROR,
919921
"WSREP has not yet prepared node for application use",
@@ -1104,8 +1106,9 @@ bool do_command(THD *thd)
11041106
/*
11051107
Bail out if DB snapshot has not been installed.
11061108
*/
1107-
if (!(server_command_flags[command] & CF_SKIP_WSREP_CHECK) &&
1108-
!wsrep_node_is_ready(thd))
1109+
if (thd->variables.wsrep_on && !thd->wsrep_applier &&
1110+
(!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE) &&
1111+
(server_command_flags[command] & CF_SKIP_WSREP_CHECK) == 0)
11091112
{
11101113
thd->protocol->end_statement();
11111114

@@ -2674,19 +2677,18 @@ mysql_execute_command(THD *thd)
26742677
}
26752678

26762679
/*
2677-
Bail out if DB snapshot has not been installed. SET and SHOW commands,
2678-
however, are always allowed.
2679-
Select query is also allowed if it does not access any table.
2680-
We additionally allow all other commands that do not change data in
2681-
case wsrep_dirty_reads is enabled.
2682-
*/
2683-
if (thd->variables.wsrep_on && !thd->wsrep_applier &&
2684-
!(wsrep_ready ||
2685-
(thd->variables.wsrep_dirty_reads &&
2686-
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) ||
2687-
wsrep_tables_accessible_when_detached(all_tables)) &&
2688-
lex->sql_command != SQLCOM_SET_OPTION &&
2689-
!wsrep_is_show_query(lex->sql_command))
2680+
* Bail out if DB snapshot has not been installed. We however,
2681+
* allow SET and SHOW queries and reads from information schema
2682+
* and dirty reads (if configured)
2683+
*/
2684+
if (thd->variables.wsrep_on &&
2685+
!thd->wsrep_applier &&
2686+
!(wsrep_ready && wsrep_reject_queries == WSREP_REJECT_NONE) &&
2687+
!(thd->variables.wsrep_dirty_reads &&
2688+
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) &&
2689+
!wsrep_tables_accessible_when_detached(all_tables) &&
2690+
lex->sql_command != SQLCOM_SET_OPTION &&
2691+
!wsrep_is_show_query(lex->sql_command))
26902692
{
26912693
my_message(ER_UNKNOWN_COM_ERROR,
26922694
"WSREP has not yet prepared node for application use", MYF(0));

sql/wsrep_var.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,12 @@ bool wsrep_reject_queries_update(sys_var *self, THD* thd, enum_var_type type)
389389
{
390390
switch (wsrep_reject_queries) {
391391
case WSREP_REJECT_NONE:
392-
wsrep_ready_set(TRUE);
393392
WSREP_INFO("Allowing client queries due to manual setting");
394393
break;
395394
case WSREP_REJECT_ALL:
396-
wsrep_ready_set(FALSE);
397395
WSREP_INFO("Rejecting client queries due to manual setting");
398396
break;
399397
case WSREP_REJECT_ALL_KILL:
400-
wsrep_ready_set(FALSE);
401398
wsrep_close_client_connections(FALSE);
402399
WSREP_INFO("Rejecting client queries and killing connections due to manual setting");
403400
break;

0 commit comments

Comments
 (0)