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: Jan Lindström <jan.lindstrom@mariadb.com>
This commit is contained in:
Daniele Sciascia 2017-03-08 13:08:21 +01:00 committed by Jan Lindström
parent 519e4322e1
commit a82611771b
3 changed files with 32 additions and 50 deletions

View File

@ -2473,9 +2473,7 @@ mysql_execute_command(THD *thd)
#endif #endif
case SQLCOM_SHOW_STATUS_PROC: case SQLCOM_SHOW_STATUS_PROC:
case SQLCOM_SHOW_STATUS_FUNC: case SQLCOM_SHOW_STATUS_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 ((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)))
goto error; goto error;
@ -2483,7 +2481,9 @@ mysql_execute_command(THD *thd)
break; break;
case SQLCOM_SHOW_STATUS: case SQLCOM_SHOW_STATUS:
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
execute_show_status(thd, all_tables); execute_show_status(thd, all_tables);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (lex->sql_command == SQLCOM_SHOW_STATUS) wsrep_free_status(thd); if (lex->sql_command == SQLCOM_SHOW_STATUS) wsrep_free_status(thd);
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
@ -2497,27 +2497,22 @@ 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_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_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: 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:
#endif /* WITH_WSREP */
{ {
#ifdef WITH_WSREP
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; thd->status_var.last_query_cost= 0.0;
/* /*
@ -3079,9 +3074,7 @@ end_with_restore_list:
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:
@ -3138,9 +3131,7 @@ end_with_restore_list:
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))
@ -3150,11 +3141,8 @@ end_with_restore_list:
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))
@ -3193,10 +3181,7 @@ end_with_restore_list:
/* 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;
} }
@ -3266,10 +3251,7 @@ end_with_restore_list:
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())
{ {
@ -3305,11 +3287,8 @@ end_with_restore_list:
} }
#endif #endif
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);
if ((res= insert_precheck(thd, all_tables))) if ((res= insert_precheck(thd, all_tables)))
break; break;
@ -3350,12 +3329,9 @@ end_with_restore_list:
} }
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 */
{ {
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); DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= insert_precheck(thd, all_tables))) if ((res= insert_precheck(thd, all_tables)))
break; break;
@ -3450,11 +3426,8 @@ end_with_restore_list:
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);
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)))
break; break;
@ -3469,11 +3442,8 @@ end_with_restore_list:
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;
multi_delete *del_result; multi_delete *del_result;
@ -3840,6 +3810,7 @@ end_with_restore_list:
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str); my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
break; break;
} }
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
res= mysqld_show_create_db(thd, lex->name.str, &lex->create_info); res= mysqld_show_create_db(thd, lex->name.str, &lex->create_info);
break; break;
} }
@ -3891,6 +3862,7 @@ end_with_restore_list:
/* 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:
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
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;
@ -4751,12 +4723,14 @@ create_sp_error:
} }
case SQLCOM_SHOW_CREATE_PROC: 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)) 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:
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
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;
@ -4769,6 +4743,7 @@ create_sp_error:
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);
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
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))
@ -4790,6 +4765,7 @@ create_sp_error:
if (check_ident_length(&lex->spname->m_name)) if (check_ident_length(&lex->spname->m_name))
goto error; goto error;
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
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. */

View File

@ -218,10 +218,15 @@ inline bool is_supported_parser_charset(CHARSET_INFO *cs)
if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \ if (WSREP(thd) || (thd && thd->wsrep_exec_mode==TOTAL_ORDER)) \
wsrep_to_isolation_end(thd); wsrep_to_isolation_end(thd);
#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_SYNC_WAIT(thd_, before_)
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */

View File

@ -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_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
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