bzr merge -r4104..4120 codership/5.6/

This commit is contained in:
Nirbhay Choubey 2014-08-12 14:05:44 -04:00
parent 38f048a013
commit 857abf1481
9 changed files with 158 additions and 66 deletions

View File

@ -5555,7 +5555,6 @@ static my_bool have_committing_connections()
if (is_committing_connection(tmp)) if (is_committing_connection(tmp))
{ {
mysql_mutex_unlock(&LOCK_thread_count);
return TRUE; return TRUE;
} }
} }

View File

@ -1200,6 +1200,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table, if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
FALSE, UINT_MAX, FALSE)) FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */ goto error; /* purecov: inspected */
WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL)
thd->enable_slow_log= opt_log_slow_admin_statements; thd->enable_slow_log= opt_log_slow_admin_statements;
res= (specialflag & SPECIAL_NO_NEW_FUNC) ? res= (specialflag & SPECIAL_NO_NEW_FUNC) ?
mysql_recreate_table(thd, first_table, true) : mysql_recreate_table(thd, first_table, true) :

View File

@ -1211,6 +1211,9 @@ static void wsrep_copy_query(THD *thd)
{ {
thd->wsrep_retry_command = thd->get_command(); thd->wsrep_retry_command = thd->get_command();
thd->wsrep_retry_query_len = thd->query_length(); 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 = (char *)my_malloc(
thd->wsrep_retry_query_len + 1, MYF(0)); thd->wsrep_retry_query_len + 1, MYF(0));
strncpy(thd->wsrep_retry_query, thd->query(), thd->wsrep_retry_query_len); strncpy(thd->wsrep_retry_query, thd->query(), thd->wsrep_retry_query_len);
@ -3793,8 +3796,7 @@ end_with_restore_list:
if ((res= insert_precheck(thd, all_tables))) if ((res= insert_precheck(thd, all_tables)))
break; break;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (lex->sql_command == SQLCOM_INSERT_SELECT && if (thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED)
thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED)
{ {
thd->wsrep_consistency_check = CONSISTENCY_CHECK_RUNNING; thd->wsrep_consistency_check = CONSISTENCY_CHECK_RUNNING;
WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL); WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL);

View File

@ -132,7 +132,7 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) {
sql_print_error("WSREP: %s", msg); sql_print_error("WSREP: %s", msg);
break; break;
case WSREP_LOG_DEBUG: case WSREP_LOG_DEBUG:
sql_print_information ("[Debug] WSREP: %s", msg); if (wsrep_debug) sql_print_information ("[Debug] WSREP: %s", msg);
default: default:
break; break;
} }
@ -794,10 +794,10 @@ void wsrep_filter_new_cluster (int* argc, char* argv[])
{ {
/* make a copy of the argument to convert possible underscores to hyphens. /* make a copy of the argument to convert possible underscores to hyphens.
* the copy need not to be longer than WSREP_NEW_CLUSTER option */ * the copy need not to be longer than WSREP_NEW_CLUSTER option */
char arg[sizeof(WSREP_NEW_CLUSTER) + 2]= { 0, }; char arg[sizeof(WSREP_NEW_CLUSTER) + 1]= { 0, };
strncpy(arg, argv[i], sizeof(arg) - 1); strncpy(arg, argv[i], sizeof(arg) - 1);
char* underscore; char* underscore(arg);
while (NULL != (underscore= strchr(arg, '_'))) *underscore= '-'; while (NULL != (underscore= strchr(underscore, '_'))) *underscore= '-';
if (!strcmp(arg, WSREP_NEW_CLUSTER)) if (!strcmp(arg, WSREP_NEW_CLUSTER))
{ {
@ -904,7 +904,7 @@ wsrep_causal_wait (THD* thd)
switch (ret) switch (ret)
{ {
case WSREP_NOT_IMPLEMENTED: case WSREP_NOT_IMPLEMENTED:
msg= "consistent reads by wsrep backend. " msg= "synchronous reads by wsrep backend. "
"Please unset wsrep_causal_reads variable."; "Please unset wsrep_causal_reads variable.";
err= ER_NOT_SUPPORTED_YET; err= ER_NOT_SUPPORTED_YET;
break; break;

View File

@ -5642,7 +5642,7 @@ wsrep_innobase_mysql_sort(
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_VARCHAR: case MYSQL_TYPE_VARCHAR:
{ {
uchar tmp_str[REC_VERSION_56_MAX_INDEX_COL_LEN]; uchar tmp_str[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'};
uint tmp_length = REC_VERSION_56_MAX_INDEX_COL_LEN; uint tmp_length = REC_VERSION_56_MAX_INDEX_COL_LEN;
/* Use the charset number to pick the right charset struct for /* Use the charset number to pick the right charset struct for
@ -5681,11 +5681,11 @@ wsrep_innobase_mysql_sort(
} else { } else {
/* strnxfrm will expand the destination string, /* strnxfrm will expand the destination string,
protocols < 3 truncated the sorted sring protocols < 3 truncated the sorted sring
protocols > 3 gets full sorted sring protocols >= 3 gets full sorted sring
*/ */
tmp_length = charset->coll->strnxfrm( tmp_length = charset->coll->strnxfrm(
charset, str, buf_length, charset, str, buf_length,
str_length, tmp_str, tmp_length, 0); str_length, tmp_str, str_length, 0);
DBUG_ASSERT(tmp_length <= buf_length); DBUG_ASSERT(tmp_length <= buf_length);
ret_length = tmp_length; ret_length = tmp_length;
} }
@ -6228,6 +6228,7 @@ UNIV_INTERN
uint uint
wsrep_store_key_val_for_row( wsrep_store_key_val_for_row(
/*===============================*/ /*===============================*/
THD* thd,
TABLE* table, TABLE* table,
uint keynr, /*!< in: key number */ uint keynr, /*!< in: key number */
char* buff, /*!< in/out: buffer for the key value (in MySQL char* buff, /*!< in/out: buffer for the key value (in MySQL
@ -6242,25 +6243,33 @@ wsrep_store_key_val_for_row(
char* buff_start = buff; char* buff_start = buff;
enum_field_types mysql_type; enum_field_types mysql_type;
Field* field; Field* field;
uint buff_space = buff_len;
DBUG_ENTER("wsrep_store_key_val_for_row"); DBUG_ENTER("wsrep_store_key_val_for_row");
memset(buff, 0, buff_len); memset(buff, 0, buff_len);
*key_is_null = TRUE; *key_is_null = TRUE;
for (; key_part != end; key_part++) { for (; key_part != end; key_part++) {
uchar sorted[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'}; uchar sorted[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'};
ibool part_is_null = FALSE; ibool part_is_null = FALSE;
if (key_part->null_bit) { if (key_part->null_bit) {
if (record[key_part->null_offset] & if (buff_space > 0) {
key_part->null_bit) { if (record[key_part->null_offset]
*buff = 1; & key_part->null_bit) {
part_is_null = TRUE; *buff = 1;
part_is_null = TRUE;
} else {
*buff = 0;
}
buff++;
buff_space--;
} else { } else {
*buff = 0; fprintf (stderr, "WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
} }
buff++;
} }
if (!part_is_null) *key_is_null = FALSE; if (!part_is_null) *key_is_null = FALSE;
@ -6280,8 +6289,15 @@ wsrep_store_key_val_for_row(
key_len = key_part->length; key_len = key_part->length;
if (part_is_null) { if (part_is_null) {
buff += key_len + 2; true_len = key_len + 2;
if (true_len > buff_space) {
fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
buff_space -= true_len;
continue; continue;
} }
cs = field->charset(); cs = field->charset();
@ -6321,13 +6337,20 @@ wsrep_store_key_val_for_row(
REC_VERSION_56_MAX_INDEX_COL_LEN); REC_VERSION_56_MAX_INDEX_COL_LEN);
if (wsrep_protocol_version > 1) { if (wsrep_protocol_version > 1) {
memcpy(buff, sorted, true_len); /* Note that we always reserve the maximum possible
/* Note that we always reserve the maximum possible length of the true VARCHAR in the key value, though
length of the true VARCHAR in the key value, though only len first bytes after the 2 length bytes contain
only len first bytes after the 2 length bytes contain actual data. The rest of the space was reset to zero
actual data. The rest of the space was reset to zero in the bzero() call above. */
in the bzero() call above. */ if (true_len > buff_space) {
buff += true_len; fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len);
buff += true_len;
buff_space -= true_len;
} else { } else {
buff += key_len; buff += key_len;
} }
@ -6351,7 +6374,15 @@ wsrep_store_key_val_for_row(
key_len = key_part->length; key_len = key_part->length;
if (part_is_null) { if (part_is_null) {
buff += key_len + 2; true_len = key_len + 2;
if (true_len > buff_space) {
fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
buff_space -= true_len;
continue; continue;
} }
@ -6394,15 +6425,22 @@ wsrep_store_key_val_for_row(
mysql_type, cs->number, sorted, true_len, mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN); REC_VERSION_56_MAX_INDEX_COL_LEN);
memcpy(buff, sorted, true_len);
/* Note that we always reserve the maximum possible /* Note that we always reserve the maximum possible
length of the BLOB prefix in the key value. */ length of the BLOB prefix in the key value. */
if (wsrep_protocol_version > 1) { if (wsrep_protocol_version > 1) {
buff += true_len; if (true_len > buff_space) {
} else { fprintf (stderr,
buff += key_len; "WSREP: key truncated: %s\n",
} wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
buff_space -= true_len;
} else {
buff += key_len;
}
memcpy(buff, sorted, true_len);
} else { } else {
/* Here we handle all other data types except the /* Here we handle all other data types except the
true VARCHAR, BLOB and TEXT. Note that the column true VARCHAR, BLOB and TEXT. Note that the column
@ -6419,9 +6457,17 @@ wsrep_store_key_val_for_row(
key_len = key_part->length; key_len = key_part->length;
if (part_is_null) { if (part_is_null) {
buff += key_len; true_len = key_len;
if (true_len > buff_space) {
fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len;
buff_space -= true_len;
continue; continue;
} }
src_start = record + key_part->offset; src_start = record + key_part->offset;
@ -6459,12 +6505,18 @@ wsrep_store_key_val_for_row(
mysql_type, cs->number, sorted, true_len, mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN); REC_VERSION_56_MAX_INDEX_COL_LEN);
if (true_len > buff_space) {
fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len); memcpy(buff, sorted, true_len);
} else { } else {
memcpy(buff, src_start, true_len); memcpy(buff, src_start, true_len);
} }
buff += true_len; buff += true_len;
buff_space -= true_len;
} }
} }
@ -9690,7 +9742,8 @@ ha_innobase::wsrep_append_keys(
ibool is_null; ibool is_null;
len = wsrep_store_key_val_for_row( len = wsrep_store_key_val_for_row(
table, 0, key, key_info->key_length, record0, &is_null); thd, table, 0, key, WSREP_MAX_SUPPORTED_KEY_LENGTH,
record0, &is_null);
if (!is_null) { if (!is_null) {
rcode = wsrep_append_key( rcode = wsrep_append_key(
@ -9712,9 +9765,6 @@ ha_innobase::wsrep_append_keys(
KEY* key_info = table->key_info + i; KEY* key_info = table->key_info + i;
if (key_info->flags & HA_NOSAME) { if (key_info->flags & HA_NOSAME) {
hasPK = true; hasPK = true;
if (i != table->s->primary_key) {
wsrep_thd_set_PA_safe(thd, FALSE);
}
} }
} }
@ -9745,7 +9795,8 @@ ha_innobase::wsrep_append_keys(
(!tab && referenced_by_foreign_key()))) { (!tab && referenced_by_foreign_key()))) {
len = wsrep_store_key_val_for_row( len = wsrep_store_key_val_for_row(
table, i, key0, key_info->key_length, thd, table, i, key0,
WSREP_MAX_SUPPORTED_KEY_LENGTH,
record0, &is_null); record0, &is_null);
if (!is_null) { if (!is_null) {
rcode = wsrep_append_key( rcode = wsrep_append_key(
@ -9755,7 +9806,6 @@ ha_innobase::wsrep_append_keys(
if (key_info->flags & HA_NOSAME || shared) if (key_info->flags & HA_NOSAME || shared)
key_appended = true; key_appended = true;
} }
else else
{ {
@ -9764,7 +9814,8 @@ ha_innobase::wsrep_append_keys(
} }
if (record1) { if (record1) {
len = wsrep_store_key_val_for_row( len = wsrep_store_key_val_for_row(
table, i, key1, key_info->key_length, thd, table, i, key1,
WSREP_MAX_SUPPORTED_KEY_LENGTH,
record1, &is_null); record1, &is_null);
if (!is_null && memcmp(key0, key1, len)) { if (!is_null && memcmp(key0, key1, len)) {
rcode = wsrep_append_key( rcode = wsrep_append_key(

View File

@ -144,6 +144,33 @@ do {\
}\ }\
} while (0) } while (0)
#ifdef WITH_WSREP
/*******************************************************************//**
Inserts a struct to the head of hash table. */
#define HASH_PREPEND(TYPE, NAME, TABLE, FOLD, DATA) \
do { \
hash_cell_t* cell3333; \
TYPE* struct3333; \
\
HASH_ASSERT_OWN(TABLE, FOLD) \
\
(DATA)->NAME = NULL; \
\
cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
\
if (cell3333->node == NULL) { \
cell3333->node = DATA; \
DATA->NAME = NULL; \
} else { \
struct3333 = (TYPE*) cell3333->node; \
\
DATA->NAME = struct3333; \
\
cell3333->node = DATA; \
} \
} while (0)
#endif /*WITH_WSREP */
#ifdef UNIV_HASH_DEBUG #ifdef UNIV_HASH_DEBUG
# define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1) # define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1)
# define HASH_INVALIDATE(DATA, NAME) *(void**) (&DATA->NAME) = (void*) -1 # define HASH_INVALIDATE(DATA, NAME) *(void**) (&DATA->NAME) = (void*) -1

View File

@ -1088,7 +1088,8 @@ lock_rec_has_to_wait(
wsrep_thd_conflict_state(trx->mysql_thd, FALSE), wsrep_thd_conflict_state(trx->mysql_thd, FALSE),
wsrep_thd_conflict_state(lock2->trx->mysql_thd, FALSE) ); wsrep_thd_conflict_state(lock2->trx->mysql_thd, FALSE) );
lock_rec_print(stderr, lock2); lock_rec_print(stderr, lock2);
abort(); return FALSE;
//abort();
} else { } else {
/* if lock2->index->n_uniq <= /* if lock2->index->n_uniq <=
lock2->index->n_user_defined_cols lock2->index->n_user_defined_cols
@ -2037,7 +2038,8 @@ lock_rec_create(
ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
if (c_lock && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
lock_t *hash = (lock_t *)c_lock->hash; lock_t *hash = (lock_t *)c_lock->hash;
lock_t *prev = NULL; lock_t *prev = NULL;
@ -2100,6 +2102,9 @@ lock_rec_create(
return(lock); return(lock);
} }
trx_mutex_exit(c_lock->trx); trx_mutex_exit(c_lock->trx);
} else if (wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
HASH_PREPEND(lock_t, hash, lock_sys->rec_hash,
lock_rec_fold(space, page_no), lock);
} else { } else {
HASH_INSERT(lock_t, hash, lock_sys->rec_hash, HASH_INSERT(lock_t, hash, lock_sys->rec_hash,
lock_rec_fold(space, page_no), lock); lock_rec_fold(space, page_no), lock);
@ -2115,7 +2120,6 @@ lock_rec_create(
ut_ad(trx_mutex_own(trx)); ut_ad(trx_mutex_own(trx));
if (type_mode & LOCK_WAIT) { if (type_mode & LOCK_WAIT) {
lock_set_lock_and_trx_wait(lock, trx); lock_set_lock_and_trx_wait(lock, trx);
} }
@ -2127,7 +2131,6 @@ lock_rec_create(
MONITOR_INC(MONITOR_RECLOCK_CREATED); MONITOR_INC(MONITOR_RECLOCK_CREATED);
MONITOR_INC(MONITOR_NUM_RECLOCK); MONITOR_INC(MONITOR_NUM_RECLOCK);
return(lock); return(lock);
} }
@ -2345,7 +2348,16 @@ lock_rec_add_to_queue(
if (lock_get_wait(lock) if (lock_get_wait(lock)
&& lock_rec_get_nth_bit(lock, heap_no)) { && lock_rec_get_nth_bit(lock, heap_no)) {
#ifdef WITH_WSREP
if (wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
if (wsrep_debug) {
fprintf(stderr,
"BF skipping wait: %lu\n",
trx->id);
lock_rec_print(stderr, lock);
}
} else
#endif
goto somebody_waits; goto somebody_waits;
} }
} }
@ -2655,7 +2667,13 @@ lock_rec_has_to_wait_in_queue(
if (heap_no < lock_rec_get_n_bits(lock) if (heap_no < lock_rec_get_n_bits(lock)
&& (p[bit_offset] & bit_mask) && (p[bit_offset] & bit_mask)
&& lock_has_to_wait(wait_lock, lock)) { && lock_has_to_wait(wait_lock, lock)) {
#ifdef WITH_WSREP
if (wsrep_thd_is_BF(wait_lock->trx->mysql_thd, FALSE) &&
wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE)) {
/* don't wait for another BF lock */
continue;
}
#endif
return(lock); return(lock);
} }
} }

View File

@ -417,12 +417,9 @@ wsrep_row_upd_check_foreign_constraints(
} }
if (foreign->referenced_table) { if (foreign->referenced_table) {
mutex_enter(&(dict_sys->mutex)); os_inc_counter(dict_sys->mutex,
foreign->referenced_table
(foreign->referenced_table ->n_foreign_key_checks_running);
->n_foreign_key_checks_running)++;
mutex_exit(&(dict_sys->mutex));
} }
/* NOTE that if the thread ends up waiting for a lock /* NOTE that if the thread ends up waiting for a lock
@ -434,20 +431,14 @@ wsrep_row_upd_check_foreign_constraints(
TRUE, foreign, table, entry, thr); TRUE, foreign, table, entry, thr);
if (foreign->referenced_table) { if (foreign->referenced_table) {
mutex_enter(&(dict_sys->mutex)); os_dec_counter(dict_sys->mutex,
foreign->referenced_table
ut_a(foreign->referenced_table ->n_foreign_key_checks_running);
->n_foreign_key_checks_running > 0);
(foreign->referenced_table
->n_foreign_key_checks_running)--;
if (opened == TRUE) { if (opened == TRUE) {
dict_table_close(foreign->referenced_table, TRUE, FALSE); dict_table_close(foreign->referenced_table, TRUE, FALSE);
opened = FALSE; opened = FALSE;
} }
mutex_exit(&(dict_sys->mutex));
} }
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {

View File

@ -362,7 +362,10 @@ case "$mode" in
# Stop the service and regardless of whether it was # Stop the service and regardless of whether it was
# running or not, start it again. # running or not, start it again.
if $0 stop $other_args; then 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 else
log_failure_msg "Failed to stop running server, so refusing to try to start." log_failure_msg "Failed to stop running server, so refusing to try to start."
exit 1 exit 1