mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merged r4014 from codership/5.5
This commit is contained in:
@ -23,7 +23,7 @@ SET(WSREP_PATCH_VERSION "10")
|
|||||||
# MariaDB addition: Revision number of the last revision merged from
|
# MariaDB addition: Revision number of the last revision merged from
|
||||||
# codership branch visible in @@visible_comment.
|
# codership branch visible in @@visible_comment.
|
||||||
# Branch : codership-mysql/5.5
|
# Branch : codership-mysql/5.5
|
||||||
SET(WSREP_PATCH_REVNO "4013") # Should be updated on every merge.
|
SET(WSREP_PATCH_REVNO "4014") # Should be updated on every merge.
|
||||||
|
|
||||||
# MariaDB: Obtain patch revision number:
|
# MariaDB: Obtain patch revision number:
|
||||||
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.
|
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.
|
||||||
|
@ -594,6 +594,7 @@ typedef struct system_variables
|
|||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
my_bool wsrep_on;
|
my_bool wsrep_on;
|
||||||
my_bool wsrep_causal_reads;
|
my_bool wsrep_causal_reads;
|
||||||
|
uint wsrep_sync_wait;
|
||||||
ulong wsrep_retry_autocommit;
|
ulong wsrep_retry_autocommit;
|
||||||
#endif
|
#endif
|
||||||
double long_query_time_double;
|
double long_query_time_double;
|
||||||
|
@ -2475,7 +2475,7 @@ mysql_execute_command(THD *thd)
|
|||||||
case SQLCOM_SHOW_STATUS_PROC:
|
case SQLCOM_SHOW_STATUS_PROC:
|
||||||
case SQLCOM_SHOW_STATUS_FUNC:
|
case SQLCOM_SHOW_STATUS_FUNC:
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd)) goto error;
|
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
|
||||||
#endif /* WITH_WSREP */
|
#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)))
|
||||||
@ -2485,7 +2485,7 @@ mysql_execute_command(THD *thd)
|
|||||||
case SQLCOM_SHOW_STATUS:
|
case SQLCOM_SHOW_STATUS:
|
||||||
{
|
{
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd)) goto error;
|
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
execute_show_status(thd, all_tables);
|
execute_show_status(thd, all_tables);
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
@ -2514,7 +2514,7 @@ mysql_execute_command(THD *thd)
|
|||||||
case SQLCOM_SHOW_INDEX_STATS:
|
case SQLCOM_SHOW_INDEX_STATS:
|
||||||
case SQLCOM_SELECT:
|
case SQLCOM_SELECT:
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd)) goto error;
|
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:
|
||||||
@ -3079,7 +3079,7 @@ end_with_restore_list:
|
|||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd)) goto error;
|
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3138,7 +3138,7 @@ end_with_restore_list:
|
|||||||
{
|
{
|
||||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd)) goto error;
|
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error;
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
|
|
||||||
if (check_table_access(thd, SELECT_ACL, all_tables,
|
if (check_table_access(thd, SELECT_ACL, all_tables,
|
||||||
@ -3149,6 +3149,10 @@ 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 */
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -3188,6 +3192,10 @@ 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
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
@ -3257,6 +3265,10 @@ end_with_restore_list:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SQLCOM_REPLACE:
|
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 */
|
||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
if (mysql_bin_log.is_open())
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
@ -3292,6 +3304,10 @@ 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 */
|
||||||
{
|
{
|
||||||
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)))
|
||||||
@ -3333,6 +3349,10 @@ 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;
|
select_result *sel_result;
|
||||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||||
@ -3429,6 +3449,10 @@ 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 */
|
||||||
{
|
{
|
||||||
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)))
|
||||||
@ -3444,6 +3468,10 @@ 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 */
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -3865,9 +3865,21 @@ static Sys_var_mybool Sys_wsrep_certify_nonPK(
|
|||||||
CMD_LINE(OPT_ARG), DEFAULT(TRUE));
|
CMD_LINE(OPT_ARG), DEFAULT(TRUE));
|
||||||
|
|
||||||
static Sys_var_mybool Sys_wsrep_causal_reads(
|
static Sys_var_mybool Sys_wsrep_causal_reads(
|
||||||
"wsrep_causal_reads", "Enable \"strictly synchronous\" semantics for read operations",
|
"wsrep_causal_reads", "(DEPRECATED) setting this variable is equivalent to setting wsrep_sync_wait READ flag",
|
||||||
SESSION_VAR(wsrep_causal_reads),
|
SESSION_VAR(wsrep_causal_reads),
|
||||||
CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
CMD_LINE(OPT_ARG), DEFAULT(FALSE),
|
||||||
|
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
|
||||||
|
ON_UPDATE(wsrep_causal_reads_update));
|
||||||
|
|
||||||
|
static Sys_var_uint Sys_wsrep_sync_wait(
|
||||||
|
"wsrep_sync_wait", "Ensure \"synchronous\" read view before executing an operation of the type specified by bitmask: 1 - READ(includes SELECT, SHOW and BEGIN/START TRANSACTION); 2 - UPDATE and DELETE; 4 - INSERT and REPLACE",
|
||||||
|
SESSION_VAR(wsrep_sync_wait),
|
||||||
|
CMD_LINE(OPT_ARG),
|
||||||
|
VALID_RANGE(WSREP_SYNC_WAIT_NONE, WSREP_SYNC_WAIT_MAX),
|
||||||
|
DEFAULT(WSREP_SYNC_WAIT_NONE),
|
||||||
|
BLOCK_SIZE(1),
|
||||||
|
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
|
||||||
|
ON_UPDATE(wsrep_sync_wait_update));
|
||||||
|
|
||||||
static const char *wsrep_OSU_method_names[]= { "TOI", "RSU", NullS };
|
static const char *wsrep_OSU_method_names[]= { "TOI", "RSU", NullS };
|
||||||
static Sys_var_enum Sys_wsrep_OSU_method(
|
static Sys_var_enum Sys_wsrep_OSU_method(
|
||||||
|
@ -161,7 +161,7 @@ bool trans_begin(THD *thd, uint flags)
|
|||||||
|
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
thd->wsrep_PA_safe= true;
|
thd->wsrep_PA_safe= true;
|
||||||
if (WSREP_CLIENT(thd) && wsrep_causal_wait(thd))
|
if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
|
|
||||||
|
@ -861,13 +861,15 @@ bool wsrep_start_replication()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool wsrep_sync_wait (THD* thd, uint mask)
|
||||||
wsrep_causal_wait (THD* thd)
|
|
||||||
{
|
{
|
||||||
if (thd->variables.wsrep_causal_reads && thd->variables.wsrep_on &&
|
if ((thd->variables.wsrep_sync_wait & mask) &&
|
||||||
|
thd->variables.wsrep_on &&
|
||||||
!thd->in_active_multi_stmt_transaction() &&
|
!thd->in_active_multi_stmt_transaction() &&
|
||||||
thd->wsrep_conflict_state != REPLAYING)
|
thd->wsrep_conflict_state != REPLAYING)
|
||||||
{
|
{
|
||||||
|
WSREP_DEBUG("wsrep_sync_wait: thd->variables.wsrep_sync_wait = %u, mask = %u",
|
||||||
|
thd->variables.wsrep_sync_wait, mask);
|
||||||
// This allows autocommit SELECTs and a first SELECT after SET AUTOCOMMIT=0
|
// This allows autocommit SELECTs and a first SELECT after SET AUTOCOMMIT=0
|
||||||
// TODO: modify to check if thd has locked any rows.
|
// TODO: modify to check if thd has locked any rows.
|
||||||
wsrep_gtid_t gtid;
|
wsrep_gtid_t gtid;
|
||||||
@ -891,7 +893,7 @@ wsrep_causal_wait (THD* thd)
|
|||||||
err= ER_NOT_SUPPORTED_YET;
|
err= ER_NOT_SUPPORTED_YET;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg= "Causal wait failed.";
|
msg= "Synchronous wait failed.";
|
||||||
err= ER_LOCK_WAIT_TIMEOUT; // NOTE: the above msg won't be displayed
|
err= ER_LOCK_WAIT_TIMEOUT; // NOTE: the above msg won't be displayed
|
||||||
// with ER_LOCK_WAIT_TIMEOUT
|
// with ER_LOCK_WAIT_TIMEOUT
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,14 @@ extern my_bool wsrep_slave_FK_checks;
|
|||||||
extern my_bool wsrep_slave_UK_checks;
|
extern my_bool wsrep_slave_UK_checks;
|
||||||
|
|
||||||
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 {
|
||||||
|
WSREP_SYNC_WAIT_NONE = 0x0,
|
||||||
|
// show, 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
|
||||||
|
};
|
||||||
|
|
||||||
// MySQL status variables
|
// MySQL status variables
|
||||||
extern my_bool wsrep_connected;
|
extern my_bool wsrep_connected;
|
||||||
@ -174,9 +182,10 @@ extern void wsrep_kill_mysql(THD *thd);
|
|||||||
/* new defines */
|
/* new defines */
|
||||||
extern void wsrep_stop_replication(THD *thd);
|
extern void wsrep_stop_replication(THD *thd);
|
||||||
extern bool wsrep_start_replication();
|
extern bool wsrep_start_replication();
|
||||||
extern bool wsrep_causal_wait(THD* thd);
|
extern bool wsrep_sync_wait (THD* thd, uint mask = WSREP_SYNC_WAIT_BEFORE_READ);
|
||||||
extern int wsrep_check_opts (int argc, char* const* argv);
|
extern int wsrep_check_opts (int argc, char* const* argv);
|
||||||
extern void wsrep_prepend_PATH (const char* path);
|
extern void wsrep_prepend_PATH (const char* path);
|
||||||
|
/* some inline functions are defined in wsrep_mysqld_inl.h */
|
||||||
|
|
||||||
/* Other global variables */
|
/* Other global variables */
|
||||||
extern wsrep_seqno_t wsrep_locked_seqno;
|
extern wsrep_seqno_t wsrep_locked_seqno;
|
||||||
|
@ -60,11 +60,29 @@ bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wsrep_causal_reads_update (sys_var *self, THD* thd, enum_var_type var_type)
|
bool wsrep_causal_reads_update (sys_var *self, THD* thd, enum_var_type var_type)
|
||||||
{
|
{
|
||||||
if (var_type == OPT_GLOBAL) {
|
// global setting should not affect session setting.
|
||||||
thd->variables.wsrep_causal_reads = global_system_variables.wsrep_causal_reads;
|
// if (var_type == OPT_GLOBAL) {
|
||||||
|
// thd->variables.wsrep_causal_reads = global_system_variables.wsrep_causal_reads;
|
||||||
|
// }
|
||||||
|
if (thd->variables.wsrep_causal_reads) {
|
||||||
|
thd->variables.wsrep_sync_wait |= WSREP_SYNC_WAIT_BEFORE_READ;
|
||||||
|
} else {
|
||||||
|
thd->variables.wsrep_sync_wait &= ~WSREP_SYNC_WAIT_BEFORE_READ;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wsrep_sync_wait_update (sys_var* self, THD* thd, enum_var_type var_type)
|
||||||
|
{
|
||||||
|
// global setting should not affect session setting.
|
||||||
|
// if (var_type == OPT_GLOBAL) {
|
||||||
|
// thd->variables.wsrep_sync_wait = global_system_variables.wsrep_sync_wait;
|
||||||
|
// }
|
||||||
|
thd->variables.wsrep_causal_reads = thd->variables.wsrep_sync_wait &
|
||||||
|
WSREP_SYNC_WAIT_BEFORE_READ;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wsrep_start_position_verify (const char* start_str)
|
static int wsrep_start_position_verify (const char* start_str)
|
||||||
|
@ -35,7 +35,8 @@ int wsrep_init_vars();
|
|||||||
#define INIT_ARGS (const char* opt)
|
#define INIT_ARGS (const char* opt)
|
||||||
|
|
||||||
extern bool wsrep_on_update UPDATE_ARGS;
|
extern bool wsrep_on_update UPDATE_ARGS;
|
||||||
extern void wsrep_causal_reads_update UPDATE_ARGS;
|
extern bool wsrep_causal_reads_update UPDATE_ARGS;
|
||||||
|
extern bool wsrep_sync_wait_update UPDATE_ARGS;
|
||||||
extern bool wsrep_start_position_check CHECK_ARGS;
|
extern bool wsrep_start_position_check CHECK_ARGS;
|
||||||
extern bool wsrep_start_position_update UPDATE_ARGS;
|
extern bool wsrep_start_position_update UPDATE_ARGS;
|
||||||
extern void wsrep_start_position_init INIT_ARGS;
|
extern void wsrep_start_position_init INIT_ARGS;
|
||||||
|
Reference in New Issue
Block a user