Commit a8261177 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`.
Signed-off-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
parent 519e4322
......@@ -2473,9 +2473,7 @@ mysql_execute_command(THD *thd)
#endif
case SQLCOM_SHOW_STATUS_PROC:
case SQLCOM_SHOW_STATUS_FUNC:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if ((res= check_table_access(thd, SELECT_ACL, all_tables, FALSE,
UINT_MAX, FALSE)))
goto error;
......@@ -2483,7 +2481,9 @@ mysql_execute_command(THD *thd)
break;
case SQLCOM_SHOW_STATUS:
{
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
execute_show_status(thd, all_tables);
#ifdef WITH_WSREP
if (lex->sql_command == SQLCOM_SHOW_STATUS) wsrep_free_status(thd);
#endif /* WITH_WSREP */
......@@ -2497,27 +2497,22 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_PLUGINS:
case SQLCOM_SHOW_FIELDS:
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 */
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
case SQLCOM_SHOW_CLIENT_STATS:
case SQLCOM_SHOW_USER_STATS:
case SQLCOM_SHOW_TABLE_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_CHARSETS:
case SQLCOM_SHOW_COLLATIONS:
case SQLCOM_SHOW_STORAGE_ENGINES:
case SQLCOM_SHOW_PROFILE:
if (lex->sql_command == SQLCOM_SELECT)
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
#endif /* WITH_WSREP */
{
thd->status_var.last_query_cost= 0.0;
/*
......@@ -3079,9 +3074,7 @@ case SQLCOM_PREPARE:
goto error;
#else
{
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
/*
Access check:
......@@ -3138,9 +3131,7 @@ case SQLCOM_PREPARE:
case SQLCOM_CHECKSUM:
{
DBUG_ASSERT(first_table == all_tables && first_table != 0);
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
if (check_table_access(thd, SELECT_ACL, all_tables,
FALSE, UINT_MAX, FALSE))
......@@ -3150,11 +3141,8 @@ case SQLCOM_PREPARE:
break;
}
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;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if (update_precheck(thd, all_tables))
......@@ -3193,10 +3181,7 @@ case SQLCOM_PREPARE:
/* if we switched from normal update, rights are checked */
if (up_result != 2)
{
#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);
if ((res= multi_update_precheck(thd, all_tables)))
break;
}
......@@ -3266,10 +3251,7 @@ case SQLCOM_PREPARE:
break;
}
case SQLCOM_REPLACE:
#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);
#ifndef DBUG_OFF
if (mysql_bin_log.is_open())
{
......@@ -3305,11 +3287,8 @@ case SQLCOM_PREPARE:
}
#endif
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);
if ((res= insert_precheck(thd, all_tables)))
break;
......@@ -3350,12 +3329,9 @@ case SQLCOM_PREPARE:
}
case SQLCOM_REPLACE_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 */
{
select_result *sel_result;
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE);
select_insert *sel_result;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= insert_precheck(thd, all_tables)))
break;
......@@ -3450,11 +3426,8 @@ case SQLCOM_PREPARE:
break;
}
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);
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= delete_precheck(thd, all_tables)))
break;
......@@ -3469,11 +3442,8 @@ case SQLCOM_PREPARE:
break;
}
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);
TABLE_LIST *aux_tables= thd->lex->auxiliary_table_list.first;
multi_delete *del_result;
......@@ -3840,6 +3810,7 @@ case SQLCOM_PREPARE:
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
break;
}
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
res= mysqld_show_create_db(thd, lex->name.str, &lex->create_info);
break;
}
......@@ -3891,6 +3862,7 @@ case SQLCOM_PREPARE:
/* lex->unit.cleanup() is called outside, no need to call it here */
break;
case SQLCOM_SHOW_CREATE_EVENT:
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
res= Events::show_create_event(thd, lex->spname->m_db,
lex->spname->m_name);
break;
......@@ -4751,12 +4723,14 @@ case SQLCOM_PREPARE:
}
case SQLCOM_SHOW_CREATE_PROC:
{
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (sp_show_create_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname))
goto error;
break;
}
case SQLCOM_SHOW_CREATE_FUNC:
{
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (sp_show_create_routine(thd, TYPE_ENUM_FUNCTION, lex->spname))
goto error;
break;
......@@ -4769,6 +4743,7 @@ case SQLCOM_PREPARE:
stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ?
TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION);
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp))
goto error;
if (!sp || sp->show_routine_code(thd))
......@@ -4790,6 +4765,7 @@ case SQLCOM_PREPARE:
if (check_ident_length(&lex->spname->m_name))
goto error;
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (show_create_trigger(thd, lex->spname))
goto error; /* Error has been already logged. */
......
......@@ -218,10 +218,15 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs)
if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \
wsrep_to_isolation_end(thd);
#define WSREP_SYNC_WAIT(thd_, before_) \
if (WSREP_CLIENT(thd_) && \
wsrep_sync_wait(thd_, before_)) goto error;
#else
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
#define WSREP_TO_ISOLATION_END
#define WSREP_SYNC_WAIT(thd_, before_)
#endif /* WITH_WSREP */
......
......@@ -105,11 +105,12 @@ extern my_bool wsrep_creating_startup_threads;
enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
enum enum_wsrep_sync_wait {
WSREP_SYNC_WAIT_NONE = 0x0,
// show, select, begin
// select, begin
WSREP_SYNC_WAIT_BEFORE_READ = 0x1,
WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE = 0x2,
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
......
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