Commit 305c1ae1 authored by Nirbhay Choubey's avatar Nirbhay Choubey

Merge of innobase changes to xtradb. (r3871..3873).

parent 8ec02bb8
...@@ -6207,7 +6207,7 @@ wsrep_innobase_mysql_sort( ...@@ -6207,7 +6207,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
...@@ -6246,11 +6246,11 @@ wsrep_innobase_mysql_sort( ...@@ -6246,11 +6246,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;
} }
...@@ -6793,6 +6793,7 @@ UNIV_INTERN ...@@ -6793,6 +6793,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
...@@ -6807,6 +6808,7 @@ wsrep_store_key_val_for_row( ...@@ -6807,6 +6808,7 @@ 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");
...@@ -6814,18 +6816,25 @@ wsrep_store_key_val_for_row( ...@@ -6814,18 +6816,25 @@ wsrep_store_key_val_for_row(
*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]
& key_part->null_bit) {
*buff = 1; *buff = 1;
part_is_null = TRUE; part_is_null = TRUE;
} else { } else {
*buff = 0; *buff = 0;
} }
buff++; buff++;
buff_space--;
} else {
fprintf (stderr, "WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
}
} }
if (!part_is_null) *key_is_null = FALSE; if (!part_is_null) *key_is_null = FALSE;
...@@ -6845,8 +6854,15 @@ wsrep_store_key_val_for_row( ...@@ -6845,8 +6854,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();
...@@ -6886,13 +6902,20 @@ wsrep_store_key_val_for_row( ...@@ -6886,13 +6902,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) {
fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
memcpy(buff, sorted, true_len);
buff += true_len; buff += true_len;
buff_space -= true_len;
} else { } else {
buff += key_len; buff += key_len;
} }
...@@ -6916,7 +6939,15 @@ wsrep_store_key_val_for_row( ...@@ -6916,7 +6939,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;
} }
...@@ -6959,15 +6990,22 @@ wsrep_store_key_val_for_row( ...@@ -6959,15 +6990,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) {
if (true_len > buff_space) {
fprintf (stderr,
"WSREP: key truncated: %s\n",
wsrep_thd_query(thd));
true_len = buff_space;
}
buff += true_len; buff += true_len;
buff_space -= true_len;
} else { } else {
buff += key_len; 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
...@@ -6984,7 +7022,15 @@ wsrep_store_key_val_for_row( ...@@ -6984,7 +7022,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; 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;
} }
...@@ -7024,12 +7070,18 @@ wsrep_store_key_val_for_row( ...@@ -7024,12 +7070,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;
} }
} }
...@@ -10323,7 +10375,8 @@ ha_innobase::wsrep_append_keys( ...@@ -10323,7 +10375,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(
...@@ -10345,9 +10398,6 @@ ha_innobase::wsrep_append_keys( ...@@ -10345,9 +10398,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);
}
} }
} }
...@@ -10378,7 +10428,8 @@ ha_innobase::wsrep_append_keys( ...@@ -10378,7 +10428,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(
...@@ -10388,7 +10439,6 @@ ha_innobase::wsrep_append_keys( ...@@ -10388,7 +10439,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
{ {
...@@ -10397,7 +10447,8 @@ ha_innobase::wsrep_append_keys( ...@@ -10397,7 +10447,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(
......
...@@ -144,6 +144,33 @@ do {\ ...@@ -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
......
...@@ -1089,7 +1089,8 @@ lock_rec_has_to_wait( ...@@ -1089,7 +1089,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
...@@ -2048,6 +2049,7 @@ lock_rec_create( ...@@ -2048,6 +2049,7 @@ 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;
...@@ -2111,6 +2113,9 @@ lock_rec_create( ...@@ -2111,6 +2113,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);
...@@ -2128,7 +2133,6 @@ lock_rec_create( ...@@ -2128,7 +2133,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);
} }
...@@ -2140,7 +2144,6 @@ lock_rec_create( ...@@ -2140,7 +2144,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);
} }
...@@ -2366,7 +2369,16 @@ lock_rec_add_to_queue( ...@@ -2366,7 +2369,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;
} }
} }
...@@ -2678,7 +2690,13 @@ lock_rec_has_to_wait_in_queue( ...@@ -2678,7 +2690,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);
} }
} }
......
...@@ -419,12 +419,9 @@ wsrep_row_upd_check_foreign_constraints( ...@@ -419,12 +419,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
...@@ -436,20 +433,14 @@ wsrep_row_upd_check_foreign_constraints( ...@@ -436,20 +433,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) {
......
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