Commit 7a219b6f authored by Daniele Sciascia's avatar Daniele Sciascia Committed by Jan Lindström

MW-86 Add separate wsrep_sync_wait bitmask value for SHOW commands

Previously, setting `wsrep_sync_wait = 1` would have an effect on
both SELECT and SHOW statements.
This patch changes wsrep_sync_wait so that bitmask value 1 is used
for SELECT statements, while bitmask value 8 is reserved for SHOW
statements.
It is still possible to achieve sync wait on both SELECT and SHOW
statements by setting `wsrep_sync_wait = 9`.
parent afbaa5c6
...@@ -2788,10 +2788,6 @@ mysql_execute_command(THD *thd) ...@@ -2788,10 +2788,6 @@ mysql_execute_command(THD *thd)
/* fall through */ /* fall through */
case SQLCOM_SHOW_STATUS_PROC: case SQLCOM_SHOW_STATUS_PROC:
case SQLCOM_SHOW_STATUS_FUNC: case SQLCOM_SHOW_STATUS_FUNC:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
case SQLCOM_SHOW_DATABASES: case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_TABLES: case SQLCOM_SHOW_TABLES:
case SQLCOM_SHOW_TRIGGERS: case SQLCOM_SHOW_TRIGGERS:
...@@ -2800,27 +2796,21 @@ mysql_execute_command(THD *thd) ...@@ -2800,27 +2796,21 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_PLUGINS: case SQLCOM_SHOW_PLUGINS:
case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_FIELDS:
case SQLCOM_SHOW_KEYS: case SQLCOM_SHOW_KEYS:
#ifndef WITH_WSREP
case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_CHARSETS:
case SQLCOM_SHOW_COLLATIONS:
case SQLCOM_SHOW_STORAGE_ENGINES:
case SQLCOM_SHOW_PROFILE:
#endif /* WITH_WSREP */
case SQLCOM_SHOW_CLIENT_STATS: case SQLCOM_SHOW_CLIENT_STATS:
case SQLCOM_SHOW_USER_STATS: case SQLCOM_SHOW_USER_STATS:
case SQLCOM_SHOW_TABLE_STATS: case SQLCOM_SHOW_TABLE_STATS:
case SQLCOM_SHOW_INDEX_STATS: case SQLCOM_SHOW_INDEX_STATS:
case SQLCOM_SELECT:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_CHARSETS:
case SQLCOM_SHOW_COLLATIONS: case SQLCOM_SHOW_COLLATIONS:
case SQLCOM_SHOW_STORAGE_ENGINES: case SQLCOM_SHOW_STORAGE_ENGINES:
case SQLCOM_SHOW_PROFILE: case SQLCOM_SHOW_PROFILE:
#endif /* WITH_WSREP */ WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
case SQLCOM_SELECT:
{ {
if (lex->sql_command == SQLCOM_SELECT)
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
thd->status_var.last_query_cost= 0.0; thd->status_var.last_query_cost= 0.0;
/* /*
...@@ -3518,9 +3508,7 @@ case SQLCOM_PREPARE: ...@@ -3518,9 +3508,7 @@ case SQLCOM_PREPARE:
goto error; goto error;
#else #else
{ {
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
/* /*
Access check: Access check:
...@@ -3584,9 +3572,7 @@ case SQLCOM_PREPARE: ...@@ -3584,9 +3572,7 @@ case SQLCOM_PREPARE:
case SQLCOM_CHECKSUM: case SQLCOM_CHECKSUM:
{ {
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (check_table_access(thd, SELECT_ACL, all_tables, if (check_table_access(thd, SELECT_ACL, all_tables,
FALSE, UINT_MAX, FALSE)) FALSE, UINT_MAX, FALSE))
...@@ -3596,11 +3582,8 @@ case SQLCOM_PREPARE: ...@@ -3596,11 +3582,8 @@ case SQLCOM_PREPARE:
break; break;
} }
case SQLCOM_UPDATE: case SQLCOM_UPDATE:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error;
#endif /* WITH_WSREP */
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
ha_rows found= 0, updated= 0; ha_rows found= 0, updated= 0;
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
if (update_precheck(thd, all_tables)) if (update_precheck(thd, all_tables))
...@@ -3639,10 +3622,7 @@ case SQLCOM_PREPARE: ...@@ -3639,10 +3622,7 @@ case SQLCOM_PREPARE:
/* if we switched from normal update, rights are checked */ /* if we switched from normal update, rights are checked */
if (up_result != 2) if (up_result != 2)
{ {
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error;
#endif /* WITH_WSREP */
if ((res= multi_update_precheck(thd, all_tables))) if ((res= multi_update_precheck(thd, all_tables)))
break; break;
} }
...@@ -3712,10 +3692,7 @@ case SQLCOM_PREPARE: ...@@ -3712,10 +3692,7 @@ case SQLCOM_PREPARE:
break; break;
} }
case SQLCOM_REPLACE: case SQLCOM_REPLACE:
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE);
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error;
#endif /* WITH_WSREP */
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
...@@ -3752,11 +3729,8 @@ case SQLCOM_PREPARE: ...@@ -3752,11 +3729,8 @@ case SQLCOM_PREPARE:
#endif #endif
/* fall through */ /* fall through */
case SQLCOM_INSERT: case SQLCOM_INSERT:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error;
#endif /* WITH_WSREP */
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE);
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
/* /*
...@@ -3809,11 +3783,8 @@ case SQLCOM_PREPARE: ...@@ -3809,11 +3783,8 @@ case SQLCOM_PREPARE:
} }
case SQLCOM_REPLACE_SELECT: case SQLCOM_REPLACE_SELECT:
case SQLCOM_INSERT_SELECT: case SQLCOM_INSERT_SELECT:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE)) goto error;
#endif /* WITH_WSREP */
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE);
select_result *sel_result; select_result *sel_result;
bool explain= MY_TEST(lex->describe); bool explain= MY_TEST(lex->describe);
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
...@@ -3927,11 +3898,8 @@ case SQLCOM_PREPARE: ...@@ -3927,11 +3898,8 @@ case SQLCOM_PREPARE:
break; break;
} }
case SQLCOM_DELETE: case SQLCOM_DELETE:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error;
#endif /* WITH_WSREP */
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
select_result *sel_result=lex->result; select_result *sel_result=lex->result;
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= delete_precheck(thd, all_tables))) if ((res= delete_precheck(thd, all_tables)))
...@@ -3951,11 +3919,8 @@ case SQLCOM_PREPARE: ...@@ -3951,11 +3919,8 @@ case SQLCOM_PREPARE:
break; break;
} }
case SQLCOM_DELETE_MULTI: case SQLCOM_DELETE_MULTI:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) goto error;
#endif /* WITH_WSREP */
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first; TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first;
bool explain= MY_TEST(lex->describe); bool explain= MY_TEST(lex->describe);
...@@ -4361,9 +4326,7 @@ case SQLCOM_PREPARE: ...@@ -4361,9 +4326,7 @@ case SQLCOM_PREPARE:
db_name.length= lex->name.length; db_name.length= lex->name.length;
strmov(db_name.str, lex->name.str); strmov(db_name.str, lex->name.str);
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (check_db_name(&db_name)) if (check_db_name(&db_name))
{ {
...@@ -4421,9 +4384,7 @@ case SQLCOM_PREPARE: ...@@ -4421,9 +4384,7 @@ case SQLCOM_PREPARE:
/* lex->unit.cleanup() is called outside, no need to call it here */ /* lex->unit.cleanup() is called outside, no need to call it here */
break; break;
case SQLCOM_SHOW_CREATE_EVENT: case SQLCOM_SHOW_CREATE_EVENT:
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
res= Events::show_create_event(thd, lex->spname->m_db, res= Events::show_create_event(thd, lex->spname->m_db,
lex->spname->m_name); lex->spname->m_name);
break; break;
...@@ -5382,18 +5343,14 @@ case SQLCOM_PREPARE: ...@@ -5382,18 +5343,14 @@ case SQLCOM_PREPARE:
} }
case SQLCOM_SHOW_CREATE_PROC: case SQLCOM_SHOW_CREATE_PROC:
{ {
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname)) if (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname))
goto error; goto error;
break; break;
} }
case SQLCOM_SHOW_CREATE_FUNC: case SQLCOM_SHOW_CREATE_FUNC:
{ {
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname)) if (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname))
goto error; goto error;
break; break;
...@@ -5406,9 +5363,7 @@ case SQLCOM_PREPARE: ...@@ -5406,9 +5363,7 @@ case SQLCOM_PREPARE:
stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ?
TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION);
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp)) if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp))
goto error; goto error;
if (!sp || sp->show_routine_code(thd)) if (!sp || sp->show_routine_code(thd))
...@@ -5430,9 +5385,7 @@ case SQLCOM_PREPARE: ...@@ -5430,9 +5385,7 @@ case SQLCOM_PREPARE:
if (check_ident_length(&lex->spname->m_name)) if (check_ident_length(&lex->spname->m_name))
goto error; goto error;
#ifdef WITH_WSREP WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (show_create_trigger(thd, lex->spname)) if (show_create_trigger(thd, lex->spname))
goto error; /* Error has been already logged. */ goto error; /* Error has been already logged. */
...@@ -5850,9 +5803,11 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables) ...@@ -5850,9 +5803,11 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables)
bool res; bool res;
system_status_var old_status_var= thd->status_var; system_status_var old_status_var= thd->status_var;
thd->initial_status_var= &old_status_var; thd->initial_status_var= &old_status_var;
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (!(res= check_table_access(thd, SELECT_ACL, all_tables, FALSE, if (!(res= check_table_access(thd, SELECT_ACL, all_tables, FALSE,
UINT_MAX, FALSE))) UINT_MAX, FALSE)))
res= execute_sqlcom_select(thd, all_tables); res= execute_sqlcom_select(thd, all_tables);
error:
/* Don't log SHOW STATUS commands to slow query log */ /* Don't log SHOW STATUS commands to slow query log */
thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED | thd->server_status&= ~(SERVER_QUERY_NO_INDEX_USED |
SERVER_QUERY_NO_GOOD_INDEX_USED); SERVER_QUERY_NO_GOOD_INDEX_USED);
......
...@@ -225,11 +225,16 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs) ...@@ -225,11 +225,16 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs)
if (WSREP(thd) && !thd->lex->no_write_to_binlog \ if (WSREP(thd) && !thd->lex->no_write_to_binlog \
&& wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error; && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto error;
#define WSREP_SYNC_WAIT(thd_, before_) \
if (WSREP_CLIENT(thd_) && \
wsrep_sync_wait(thd_, before_)) goto error;
#else #else
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
#define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_END
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
#define WSREP_SYNC_WAIT(thd_, before_)
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
......
...@@ -118,11 +118,12 @@ enum enum_wsrep_OSU_method { ...@@ -118,11 +118,12 @@ enum enum_wsrep_OSU_method {
enum enum_wsrep_sync_wait { enum enum_wsrep_sync_wait {
WSREP_SYNC_WAIT_NONE = 0x0, WSREP_SYNC_WAIT_NONE = 0x0,
// show, select, begin // select, begin
WSREP_SYNC_WAIT_BEFORE_READ = 0x1, WSREP_SYNC_WAIT_BEFORE_READ = 0x1,
WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE = 0x2, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE = 0x2,
WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE = 0x4, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE = 0x4,
WSREP_SYNC_WAIT_MAX = 0x7 WSREP_SYNC_WAIT_BEFORE_SHOW = 0x8,
WSREP_SYNC_WAIT_MAX = 0xF
}; };
// MySQL status variables // MySQL status variables
......
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