1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge branch '10.2' into 10.3

This commit is contained in:
Sergei Golubchik
2018-03-28 17:06:27 +02:00
344 changed files with 8784 additions and 6890 deletions

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
Copyright (c) 2008, 2017, MariaDB
Copyright (c) 2008, 2018, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -501,6 +501,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;
for (uint i= COM_MDB_GAP_BEG; i <= COM_MDB_GAP_END; i++)
{
@ -514,6 +515,8 @@ void init_update_queries(void)
server_command_flags[COM_QUERY]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_SET_OPTION]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_STMT_PREPARE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
server_command_flags[COM_STMT_EXECUTE]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_STMT_FETCH]= CF_SKIP_WSREP_CHECK;
server_command_flags[COM_STMT_CLOSE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
server_command_flags[COM_STMT_RESET]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
server_command_flags[COM_STMT_EXECUTE]= CF_SKIP_WSREP_CHECK;
@ -1168,21 +1171,21 @@ static enum enum_server_command fetch_command(THD *thd, char *packet)
}
#ifndef EMBEDDED_LIBRARY
#ifdef WITH_WSREP
static bool wsrep_node_is_ready(THD *thd)
static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables)
{
if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready)
for (const TABLE_LIST *table= tables; table; table= table->next_global)
{
my_message(ER_UNKNOWN_COM_ERROR,
"WSREP has not yet prepared node for application use",
MYF(0));
return false;
TABLE_CATEGORY c;
LEX_CSTRING db= table->db, tn= table->table_name;
c= get_table_category(&db, &tn);
if (c != TABLE_CATEGORY_INFORMATION && c != TABLE_CATEGORY_PERFORMANCE)
return false;
}
return true;
}
#endif
#endif /* WITH_WSREP */
#ifndef EMBEDDED_LIBRARY
/**
Read one command from connection and execute it (query or simple command).
@ -1359,8 +1362,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();
@ -3437,20 +3441,23 @@ 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 (lex->sql_command != SQLCOM_SET_OPTION &&
!wsrep_is_show_query(lex->sql_command) &&
!(thd->variables.wsrep_dirty_reads &&
!is_update_query(lex->sql_command)) &&
!(lex->sql_command == SQLCOM_SELECT &&
!all_tables) &&
!wsrep_node_is_ready(thd))
* 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));
goto error;
}
}
#endif /* WITH_WSREP */
status_var_increment(thd->status_var.com_stat[lex->sql_command]);
@ -6059,9 +6066,6 @@ end_with_restore_list:
sp_head *sp;
const Sp_handler *sph= Sp_handler::handler(lex->sql_command);
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
#endif /* WITH_WSREP */
if (sph->sp_resolve_package_routine(thd, thd->lex->sphead,
lex->spname, &sph, &pkgname))
return true;
@ -7840,7 +7844,6 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
thd->wsrep_conflict_state == CERT_FAILURE)
{
thd->reset_for_next_command();
thd->reset_killed();
if (is_autocommit &&
thd->lex->sql_command != SQLCOM_SELECT &&
(thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit))
@ -7870,17 +7873,18 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
thd->variables.wsrep_retry_autocommit, thd->query());
my_message(ER_LOCK_DEADLOCK, "Deadlock: wsrep aborted transaction",
MYF(0));
thd->reset_killed();
thd->wsrep_conflict_state= NO_CONFLICT;
if (thd->wsrep_conflict_state != REPLAYING)
thd->wsrep_retry_counter= 0; // reset
}
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
thd->reset_killed();
}
else
{
set_if_smaller(thd->wsrep_retry_counter, 0); // reset; eventually ok
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
}
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
}
/* If retry is requested clean up explain structure */