Commit 4788577c authored by Nirbhay Choubey's avatar Nirbhay Choubey

bzr merge -r3997..4010 codership-mysql/5.5

parent ec91eea8
......@@ -1468,17 +1468,21 @@ end:
thd->security_ctx->master_access |= SUPER_ACL;
#ifdef WITH_WSREP
// sql_print_information("sizeof(LEX) = %d", sizeof(struct LEX));
// sizeof(LEX) = 4512, so it's relatively safe to allocate it on stack.
LEX lex;
lex.sql_command = SQLCOM_DROP_EVENT;
thd->lex = &lex;
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
if (WSREP(thd)) {
// sql_print_information("sizeof(LEX) = %d", sizeof(struct LEX));
// sizeof(LEX) = 4512, so it's relatively safe to allocate it on stack.
LEX lex;
lex.sql_command = SQLCOM_DROP_EVENT;
LEX* saved = thd->lex;
thd->lex = &lex;
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
thd->lex = saved;
}
#endif
ret= Events::drop_event(thd, dbname, name, FALSE);
#ifdef WITH_WSREP
#ifdef WITH_WSREP
WSREP_TO_ISOLATION_END;
error:
#endif
......
......@@ -993,6 +993,9 @@ static void wsrep_copy_query(THD *thd)
{
thd->wsrep_retry_command = thd->command;
thd->wsrep_retry_query_len = thd->query_length();
if (thd->wsrep_retry_query) {
my_free(thd->wsrep_retry_query);
}
thd->wsrep_retry_query = (char *)my_malloc(
thd->wsrep_retry_query_len + 1, MYF(0));
strncpy(thd->wsrep_retry_query, thd->query(), thd->wsrep_retry_query_len);
......
......@@ -3918,6 +3918,18 @@ static Sys_var_mybool Sys_wsrep_load_data_splitting(
GLOBAL_VAR(wsrep_load_data_splitting),
CMD_LINE(OPT_ARG), DEFAULT(TRUE));
static Sys_var_mybool Sys_wsrep_slave_FK_checks(
"wsrep_slave_FK_checks", "Should slave thread do "
"foreign key constraint checks",
GLOBAL_VAR(wsrep_slave_FK_checks),
CMD_LINE(OPT_ARG), DEFAULT(TRUE));
static Sys_var_mybool Sys_wsrep_slave_UK_checks(
"wsrep_slave_UK_checks", "Should slave thread do "
"secondary index uniqueness chesks",
GLOBAL_VAR(wsrep_slave_UK_checks),
CMD_LINE(OPT_ARG), DEFAULT(FALSE));
static Sys_var_mybool Sys_wsrep_restart_slave(
"wsrep_restart_slave", "Should MySQL slave be restarted automatically, when node joins back to cluster",
GLOBAL_VAR(wsrep_restart_slave), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
......
......@@ -207,6 +207,17 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx,
thd_proc_info(thd, "applying write set");
#endif /* WSREP_PROC_INFO */
/* tune FK and UK checking policy */
if (wsrep_slave_UK_checks == FALSE)
thd->variables.option_bits|= OPTION_RELAXED_UNIQUE_CHECKS;
else
thd->variables.option_bits&= ~OPTION_RELAXED_UNIQUE_CHECKS;
if (wsrep_slave_FK_checks == FALSE)
thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS;
else
thd->variables.option_bits&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
if (flags & WSREP_FLAG_ISOLATION)
{
thd->wsrep_apply_toi= true;
......
......@@ -51,7 +51,7 @@ ulong wsrep_max_ws_size = 1073741824UL;//max ws (RBR buffer) size
ulong wsrep_max_ws_rows = 65536; // max number of rows in ws
int wsrep_to_isolation = 0; // # of active TO isolation threads
my_bool wsrep_certify_nonPK = 1; // certify, even when no primary key
long wsrep_max_protocol_version = 2; // maximum protocol version to use
long wsrep_max_protocol_version = 3; // maximum protocol version to use
ulong wsrep_forced_binlog_format = BINLOG_FORMAT_UNSPEC;
my_bool wsrep_recovery = 0; // recovery
my_bool wsrep_replicate_myisam = 0; // enable myisam replication
......@@ -64,6 +64,8 @@ my_bool wsrep_restart_slave = 0; // should mysql slave thread be
// restarted, if node joins back
my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave
// restart will be needed
my_bool wsrep_slave_UK_checks = 0; // slave thread does UK checks
my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks
/*
* End configuration options
*/
......@@ -109,7 +111,7 @@ const char* wsrep_provider_vendor = provider_vendor;
wsrep_uuid_t local_uuid = WSREP_UUID_UNDEFINED;
wsrep_seqno_t local_seqno = WSREP_SEQNO_UNDEFINED;
wsp::node_status local_status;
long wsrep_protocol_version = 2;
long wsrep_protocol_version = 3;
// Boolean denoting if server is in initial startup phase. This is needed
// to make sure that main thread waiting in wsrep_sst_wait() is signaled
......@@ -130,7 +132,7 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) {
sql_print_error("WSREP: %s", msg);
break;
case WSREP_LOG_DEBUG:
sql_print_information ("[Debug] WSREP: %s", msg);
if (wsrep_debug) sql_print_information ("[Debug] WSREP: %s", msg);
default:
break;
}
......@@ -252,6 +254,7 @@ wsrep_view_handler_cb (void* app_ctx,
case 0:
case 1:
case 2:
case 3:
// version change
if (view->proto_ver != wsrep_protocol_version)
{
......@@ -356,7 +359,7 @@ wsrep_view_handler_cb (void* app_ctx,
}
out:
wsrep_startup= FALSE;
if (view->status == WSREP_VIEW_PRIMARY) wsrep_startup= FALSE;
local_status.set(new_status, view);
return WSREP_CB_SUCCESS;
......@@ -948,6 +951,7 @@ static bool wsrep_prepare_key_for_isolation(const char* db,
break;
case 1:
case 2:
case 3:
{
*key_len= 0;
if (db)
......@@ -1079,6 +1083,7 @@ bool wsrep_prepare_key_for_innodb(const uchar* cache_key,
}
case 1:
case 2:
case 3:
{
key[0].ptr = cache_key;
key[0].len = strlen( (char*)cache_key );
......@@ -1279,6 +1284,14 @@ static void wsrep_TOI_end(THD *thd) {
WSREP_DEBUG("TO END: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd),
thd->wsrep_exec_mode, (thd->query()) ? thd->query() : "void");
XID xid;
wsrep_xid_init(&xid, &thd->wsrep_trx_meta.gtid.uuid,
thd->wsrep_trx_meta.gtid.seqno);
wsrep_set_SE_checkpoint(&xid);
WSREP_DEBUG("TO END: %lld, update seqno",
(long long)wsrep_thd_trx_seqno(thd));
if (WSREP_OK == (ret = wsrep->to_execute_end(wsrep, thd->thread_id))) {
WSREP_DEBUG("TO END: %lld", (long long)wsrep_thd_trx_seqno(thd));
}
......
......@@ -97,6 +97,8 @@ extern ulong wsrep_mysql_replication_bundle;
extern my_bool wsrep_load_data_splitting;
extern my_bool wsrep_restart_slave;
extern my_bool wsrep_restart_slave_activated;
extern my_bool wsrep_slave_FK_checks;
extern my_bool wsrep_slave_UK_checks;
enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
......
......@@ -414,6 +414,17 @@ void wsrep_create_rollbacker()
}
}
extern "C"
void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe)
{
if (thd_ptr)
{
THD* thd = (THD*)thd_ptr;
thd->wsrep_PA_safe = safe;
}
}
extern "C"
my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync)
{
......
......@@ -25,6 +25,7 @@ void wsrep_create_appliers(long threads);
void wsrep_create_rollbacker();
extern "C" my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
extern "C" void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
extern "C" my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync);
extern "C" my_bool wsrep_thd_is_local(void *thd_ptr, my_bool sync);
extern "C" int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
......
......@@ -4572,18 +4572,21 @@ innobase_mysql_cmp(
}
#ifdef WITH_WSREP
extern "C" UNIV_INTERN
void
int
wsrep_innobase_mysql_sort(
/*===============*/
/* out: str contains sort string */
int mysql_type, /* in: MySQL type */
uint charset_number, /* in: number of the charset */
unsigned char* str, /* in: data field */
unsigned int str_length) /* in: data field length,
unsigned int str_length, /* in: data field length,
not UNIV_SQL_NULL */
unsigned int buf_length) /* in: total str buffer length */
{
CHARSET_INFO* charset;
enum_field_types mysql_tp;
int ret_length = str_length;
DBUG_ASSERT(str_length != UNIV_SQL_NULL);
......@@ -4627,9 +4630,29 @@ wsrep_innobase_mysql_sort(
ut_a(str_length <= tmp_length);
memcpy(tmp_str, str, str_length);
tmp_length = charset->coll->strnxfrm(charset, str, str_length,
tmp_str, str_length);
DBUG_ASSERT(tmp_length <= str_length);
if (wsrep_protocol_version < 3) {
tmp_length = charset->coll->strnxfrm(
charset, str, str_length,
tmp_str, str_length);
DBUG_ASSERT(tmp_length <= str_length);
} else {
/* strnxfrm will expand the destination string,
protocols < 3 truncated the sorted sring
protocols > 3 gets full sorted sring
*/
/* 5.5 strnxfrm pads the tail with spaces and
always returns the full destination buffer lenght
we cannot know how many characters were converted
using 2 * str length here as best guess
*/
uint dst_length = (str_length * 2 < tmp_length) ?
(str_length * 2) : tmp_length;
tmp_length = charset->coll->strnxfrm(
charset, str, dst_length,
tmp_str, str_length);
DBUG_ASSERT(tmp_length <= buf_length);
ret_length = tmp_length;
}
break;
}
......@@ -4657,7 +4680,7 @@ wsrep_innobase_mysql_sort(
break;
}
return;
return ret_length;
}
#endif // WITH_WSREP
/**************************************************************//**
......@@ -4871,8 +4894,9 @@ wsrep_store_key_val_for_row(
}
memcpy(sorted, data, true_len);
wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len);
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
if (wsrep_protocol_version > 1) {
memcpy(buff, sorted, true_len);
......@@ -4944,8 +4968,9 @@ wsrep_store_key_val_for_row(
}
memcpy(sorted, blob_data, true_len);
wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len);
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
memcpy(buff, sorted, true_len);
......@@ -5008,8 +5033,10 @@ wsrep_store_key_val_for_row(
&error);
}
memcpy(sorted, src_start, true_len);
wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len);
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
memcpy(buff, sorted, true_len);
} else {
memcpy(buff, src_start, true_len);
......@@ -7269,7 +7296,7 @@ wsrep_append_foreign_key(
wsrep_thd_query(thd) : "void");
return DB_ERROR;
}
byte key[WSREP_MAX_SUPPORTED_KEY_LENGTH+1];
byte key[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'};
ulint len = WSREP_MAX_SUPPORTED_KEY_LENGTH;
dict_index_t *idx_target = (referenced) ?
......@@ -7439,11 +7466,11 @@ ha_innobase::wsrep_append_keys(
uint len;
char keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'};
char *key = &keyval[0];
KEY *key_info = table->key_info;
ibool is_null;
len = wsrep_store_key_val_for_row(
table, 0, key, key_info->key_length, record0, &is_null);
table, 0, key, WSREP_MAX_SUPPORTED_KEY_LENGTH,
record0, &is_null);
if (!is_null) {
int rcode = wsrep_append_key(
......@@ -7461,9 +7488,14 @@ ha_innobase::wsrep_append_keys(
uint i;
bool hasPK= false;
for (i=0; i<table->s->keys && !hasPK; ++i) {
for (i=0; i<table->s->keys; ++i) {
KEY* key_info = table->key_info + i;
if (key_info->flags & HA_NOSAME) hasPK = true;
if (key_info->flags & HA_NOSAME) {
hasPK = true;
if (i != table->s->primary_key) {
wsrep_thd_set_PA_safe(thd, FALSE);
}
}
}
for (i=0; i<table->s->keys; ++i) {
......@@ -7486,13 +7518,15 @@ ha_innobase::wsrep_append_keys(
table->s->table_name.str,
key_info->name);
}
/* !hasPK == table with no PK, must append all non-unique keys */
if (!hasPK || key_info->flags & HA_NOSAME ||
((tab &&
dict_table_get_referenced_constraint(tab, idx)) ||
(!tab && referenced_by_foreign_key()))) {
len = wsrep_store_key_val_for_row(
table, i, key0, key_info->key_length,
table, i, key0,
WSREP_MAX_SUPPORTED_KEY_LENGTH,
record0, &is_null);
if (!is_null) {
int rcode = wsrep_append_key(
......@@ -7510,7 +7544,8 @@ ha_innobase::wsrep_append_keys(
}
if (record1) {
len = wsrep_store_key_val_for_row(
table, i, key1, key_info->key_length,
table, i, key1,
WSREP_MAX_SUPPORTED_KEY_LENGTH,
record1, &is_null);
if (!is_null && memcmp(key0, key1, len)) {
int rcode = wsrep_append_key(
......@@ -12846,6 +12881,7 @@ static int innobase_wsrep_set_checkpoint(handlerton* hton, const XID* xid)
trx_sysf_t* sys_header = trx_sysf_get(&mtr);
trx_sys_update_wsrep_checkpoint(xid, sys_header, &mtr);
mtr_commit(&mtr);
innobase_flush_logs(hton);
return 0;
} else {
return 1;
......
......@@ -291,11 +291,12 @@ UNIV_INTERN int wsrep_innobase_kill_one_trx(void *thd, trx_t *bf_trx, trx_t *vic
my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
//int64_t wsrep_thd_trx_seqno(THD *thd);
int wsrep_trx_order_before(void *thd1, void *thd2);
void wsrep_innobase_mysql_sort(int mysql_type, uint charset_number,
unsigned char* str, unsigned int str_length);
int
wsrep_on(void *thd_ptr);
int wsrep_innobase_mysql_sort(int mysql_type, uint charset_number,
unsigned char* str, unsigned int str_length,
unsigned int buf_length);
int wsrep_on(void *thd_ptr);
int wsrep_is_wsrep_xid(const void*);
my_bool wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
#endif /* WITH_WSREP */
/**********************************************************************//**
Get the current setting of the lower_case_table_names global parameter from
......
......@@ -1820,12 +1820,7 @@ lock_rec_create(
automatically of the gap type */
if (UNIV_UNLIKELY(heap_no == PAGE_HEAP_NO_SUPREMUM)) {
#ifdef WITH_WSREP
ut_ad(!(type_mode & LOCK_REC_NOT_GAP) ||
wsrep_thd_is_BF(trx->mysql_thd, FALSE));
#else
ut_ad(!(type_mode & LOCK_REC_NOT_GAP));
#endif /* WITH_WSREP */
type_mode = type_mode & ~(LOCK_GAP | LOCK_REC_NOT_GAP);
}
......@@ -2109,12 +2104,7 @@ lock_rec_add_to_queue(
struct for a gap type lock */
if (UNIV_UNLIKELY(heap_no == PAGE_HEAP_NO_SUPREMUM)) {
#ifdef WITH_WSREP
ut_ad(!(type_mode & LOCK_REC_NOT_GAP) ||
wsrep_thd_is_BF(trx->mysql_thd, FALSE));
#else
ut_ad(!(type_mode & LOCK_REC_NOT_GAP));
#endif /* WITH_WSREP */
/* There should never be LOCK_REC_NOT_GAP on a supremum
record, but let us play safe */
......
......@@ -1961,10 +1961,10 @@ wsrep_rec_get_foreign_key(
key_len++;
}
memcpy(buf, data, len);
wsrep_innobase_mysql_sort(
*buf_len = wsrep_innobase_mysql_sort(
(int)(col_f->prtype & DATA_MYSQL_TYPE_MASK),
(uint)dtype_get_charset_coll(col_f->prtype),
buf, len);
buf, len, *buf_len);
} else { /* new protocol */
if (!(col_r->prtype & DATA_NOT_NULL)) {
*buf++ = 0;
......@@ -1994,12 +1994,12 @@ wsrep_rec_get_foreign_key(
case DATA_MYSQL:
/* Copy the actual data */
ut_memcpy(buf, data, len);
wsrep_innobase_mysql_sort(
len = wsrep_innobase_mysql_sort(
(int)
(col_f->prtype & DATA_MYSQL_TYPE_MASK),
(uint)
dtype_get_charset_coll(col_f->prtype),
buf, len);
buf, len, *buf_len);
break;
case DATA_BLOB:
case DATA_BINARY:
......
......@@ -1760,13 +1760,6 @@ row_ins_scan_sec_index_for_duplicate(
lock_type, block, rec, index, offsets, thr);
} else {
#ifdef WITH_WSREP
if (wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0)) {
if (!(lock_type & LOCK_REC_NOT_GAP)) {
lock_type |= LOCK_REC_NOT_GAP;
}
}
#endif /* WITH_WSREP */
err = row_ins_set_shared_rec_lock(
lock_type, block, rec, index, offsets, thr);
}
......
......@@ -364,7 +364,10 @@ case "$mode" in
# Stop the service and regardless of whether it was
# running or not, start it again.
if $0 stop $other_args; then
$0 start $other_args
if ! $0 start $other_args; then
log_failure_msg "Failed to restart server."
exit 1
fi
else
log_failure_msg "Failed to stop running server, so refusing to try to start."
exit 1
......
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