diff options
author | Nirbhay Choubey <nirbhay@skysql.com> | 2014-08-12 16:39:10 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@skysql.com> | 2014-08-12 16:39:10 -0400 |
commit | 305c1ae157de414bbd3e4a89cddbe522eaa1a309 (patch) | |
tree | 12e46d8bc993dfbb793bae746d507dda261e5b34 /storage | |
parent | 8ec02bb836ab43d115579e6ba14f669e7dcd3e82 (diff) | |
download | mariadb-git-305c1ae157de414bbd3e4a89cddbe522eaa1a309.tar.gz |
Merge of innobase changes to xtradb. (r3871..3873).
Diffstat (limited to 'storage')
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 123 | ||||
-rw-r--r-- | storage/xtradb/include/hash0hash.h | 27 | ||||
-rw-r--r-- | storage/xtradb/lock/lock0lock.cc | 30 | ||||
-rw-r--r-- | storage/xtradb/row/row0upd.cc | 21 |
4 files changed, 144 insertions, 57 deletions
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 66e9ae1f7b5..4f2305f9ff6 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -6207,7 +6207,7 @@ wsrep_innobase_mysql_sort( case MYSQL_TYPE_LONG_BLOB: 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; /* Use the charset number to pick the right charset struct for @@ -6246,11 +6246,11 @@ wsrep_innobase_mysql_sort( } else { /* strnxfrm will expand the destination string, protocols < 3 truncated the sorted sring - protocols > 3 gets full sorted sring + protocols >= 3 gets full sorted sring */ tmp_length = charset->coll->strnxfrm( charset, str, buf_length, - str_length, tmp_str, tmp_length, 0); + str_length, tmp_str, str_length, 0); DBUG_ASSERT(tmp_length <= buf_length); ret_length = tmp_length; } @@ -6793,6 +6793,7 @@ UNIV_INTERN uint wsrep_store_key_val_for_row( /*===============================*/ + THD* thd, TABLE* table, uint keynr, /*!< in: key number */ char* buff, /*!< in/out: buffer for the key value (in MySQL @@ -6807,25 +6808,33 @@ wsrep_store_key_val_for_row( char* buff_start = buff; enum_field_types mysql_type; Field* field; - + uint buff_space = buff_len; + DBUG_ENTER("wsrep_store_key_val_for_row"); memset(buff, 0, buff_len); *key_is_null = TRUE; for (; key_part != end; key_part++) { + uchar sorted[REC_VERSION_56_MAX_INDEX_COL_LEN] = {'\0'}; ibool part_is_null = FALSE; if (key_part->null_bit) { - if (record[key_part->null_offset] & - key_part->null_bit) { - *buff = 1; - part_is_null = TRUE; + if (buff_space > 0) { + if (record[key_part->null_offset] + & key_part->null_bit) { + *buff = 1; + part_is_null = TRUE; + } else { + *buff = 0; + } + buff++; + buff_space--; } else { - *buff = 0; + fprintf (stderr, "WSREP: key truncated: %s\n", + wsrep_thd_query(thd)); } - buff++; } if (!part_is_null) *key_is_null = FALSE; @@ -6845,8 +6854,15 @@ wsrep_store_key_val_for_row( key_len = key_part->length; 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; } cs = field->charset(); @@ -6886,13 +6902,20 @@ wsrep_store_key_val_for_row( REC_VERSION_56_MAX_INDEX_COL_LEN); if (wsrep_protocol_version > 1) { - memcpy(buff, sorted, true_len); - /* Note that we always reserve the maximum possible - length of the true VARCHAR in the key value, though - only len first bytes after the 2 length bytes contain - actual data. The rest of the space was reset to zero - in the bzero() call above. */ - buff += true_len; + /* Note that we always reserve the maximum possible + length of the true VARCHAR in the key value, though + only len first bytes after the 2 length bytes contain + actual data. The rest of the space was reset to zero + 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_space -= true_len; } else { buff += key_len; } @@ -6916,7 +6939,15 @@ wsrep_store_key_val_for_row( key_len = key_part->length; 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; } @@ -6959,15 +6990,22 @@ wsrep_store_key_val_for_row( mysql_type, cs->number, sorted, true_len, REC_VERSION_56_MAX_INDEX_COL_LEN); - memcpy(buff, sorted, true_len); /* Note that we always reserve the maximum possible length of the BLOB prefix in the key value. */ if (wsrep_protocol_version > 1) { - buff += true_len; - } else { - buff += 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; + } else { + buff += key_len; + } + memcpy(buff, sorted, true_len); } else { /* Here we handle all other data types except the true VARCHAR, BLOB and TEXT. Note that the column @@ -6984,9 +7022,17 @@ wsrep_store_key_val_for_row( key_len = key_part->length; 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; @@ -7024,12 +7070,18 @@ wsrep_store_key_val_for_row( mysql_type, cs->number, sorted, true_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); } else { 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( ibool is_null; 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) { rcode = wsrep_append_key( @@ -10345,9 +10398,6 @@ ha_innobase::wsrep_append_keys( KEY* key_info = table->key_info + i; if (key_info->flags & HA_NOSAME) { hasPK = true; - if (i != table->s->primary_key) { - wsrep_thd_set_PA_safe(thd, FALSE); - } } } @@ -10378,7 +10428,8 @@ ha_innobase::wsrep_append_keys( (!tab && referenced_by_foreign_key()))) { 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); if (!is_null) { rcode = wsrep_append_key( @@ -10388,7 +10439,6 @@ ha_innobase::wsrep_append_keys( if (key_info->flags & HA_NOSAME || shared) key_appended = true; - } else { @@ -10397,7 +10447,8 @@ ha_innobase::wsrep_append_keys( } if (record1) { 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); if (!is_null && memcmp(key0, key1, len)) { rcode = wsrep_append_key( diff --git a/storage/xtradb/include/hash0hash.h b/storage/xtradb/include/hash0hash.h index a6fe4e680a1..68d3c6ace4e 100644 --- a/storage/xtradb/include/hash0hash.h +++ b/storage/xtradb/include/hash0hash.h @@ -144,6 +144,33 @@ do {\ }\ } 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 # define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1) # define HASH_INVALIDATE(DATA, NAME) *(void**) (&DATA->NAME) = (void*) -1 diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 97d4ed77c9c..645bad7f26c 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1089,7 +1089,8 @@ lock_rec_has_to_wait( wsrep_thd_conflict_state(trx->mysql_thd, FALSE), wsrep_thd_conflict_state(lock2->trx->mysql_thd, FALSE) ); lock_rec_print(stderr, lock2); - abort(); + return FALSE; + //abort(); } else { /* if lock2->index->n_uniq <= lock2->index->n_user_defined_cols @@ -2048,7 +2049,8 @@ lock_rec_create( ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); #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 *prev = NULL; @@ -2111,6 +2113,9 @@ lock_rec_create( return(lock); } 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 { HASH_INSERT(lock_t, hash, lock_sys->rec_hash, lock_rec_fold(space, page_no), lock); @@ -2128,7 +2133,6 @@ lock_rec_create( ut_ad(trx_mutex_own(trx)); if (type_mode & LOCK_WAIT) { - lock_set_lock_and_trx_wait(lock, trx); } @@ -2140,7 +2144,6 @@ lock_rec_create( MONITOR_INC(MONITOR_RECLOCK_CREATED); MONITOR_INC(MONITOR_NUM_RECLOCK); - return(lock); } @@ -2366,7 +2369,16 @@ lock_rec_add_to_queue( if (lock_get_wait(lock) && 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; } } @@ -2678,7 +2690,13 @@ lock_rec_has_to_wait_in_queue( if (heap_no < lock_rec_get_n_bits(lock) && (p[bit_offset] & bit_mask) && 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); } } diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 4b8dff7b47f..bdd2a691368 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -419,12 +419,9 @@ wsrep_row_upd_check_foreign_constraints( } if (foreign->referenced_table) { - mutex_enter(&(dict_sys->mutex)); - - (foreign->referenced_table - ->n_foreign_key_checks_running)++; - - mutex_exit(&(dict_sys->mutex)); + os_inc_counter(dict_sys->mutex, + foreign->referenced_table + ->n_foreign_key_checks_running); } /* NOTE that if the thread ends up waiting for a lock @@ -436,20 +433,14 @@ wsrep_row_upd_check_foreign_constraints( TRUE, foreign, table, entry, thr); if (foreign->referenced_table) { - mutex_enter(&(dict_sys->mutex)); - - ut_a(foreign->referenced_table - ->n_foreign_key_checks_running > 0); - - (foreign->referenced_table - ->n_foreign_key_checks_running)--; + os_dec_counter(dict_sys->mutex, + foreign->referenced_table + ->n_foreign_key_checks_running); if (opened == TRUE) { dict_table_close(foreign->referenced_table, TRUE, FALSE); opened = FALSE; } - - mutex_exit(&(dict_sys->mutex)); } if (err != DB_SUCCESS) { |