diff options
Diffstat (limited to 'storage/innobase')
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 99 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.h | 2 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.c | 32 |
3 files changed, 68 insertions, 65 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7cc21ce5a8e..83f559e5161 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -120,9 +120,9 @@ extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_wsrep_rollback; extern MYSQL_PLUGIN_IMPORT mysql_cond_t COND_wsrep_rollback; extern MYSQL_PLUGIN_IMPORT wsrep_aborting_thd_t wsrep_aborting_thd; -static inline wsrep_trx_handle_t* -wsrep_trx_handle(THD* thd, const trx_t* trx) { - return wsrep_trx_handle_for_id(wsrep_thd_trx_handle(thd), +static inline wsrep_ws_handle_t* +wsrep_ws_handle(THD* thd, const trx_t* trx) { + return wsrep_ws_handle_for_trx(wsrep_thd_ws_handle(thd), (wsrep_trx_id_t)trx->id); } @@ -130,7 +130,7 @@ extern bool wsrep_prepare_key_for_innodb(const uchar *cache_key, size_t cache_key_len, const uchar* row_id, size_t row_id_len, - wsrep_key_part_t* key, + wsrep_buf_t* key, size_t* key_len); extern handlerton * wsrep_hton; @@ -7182,6 +7182,7 @@ wsrep_append_foreign_key( ulint rcode = DB_SUCCESS; char cache_key[513] = {'\0'}; int cache_key_len; + bool const copy = true; if (!wsrep_on(trx->mysql_thd) || wsrep_thd_exec_mode(thd) != LOCAL_STATE) @@ -7308,30 +7309,31 @@ wsrep_append_foreign_key( foreign->foreign_table->name); } - wsrep_key_part_t wkey_part[3]; + wsrep_buf_t wkey_part[3]; wsrep_key_t wkey = {wkey_part, 3}; if (!wsrep_prepare_key_for_innodb( (const uchar*)cache_key, cache_key_len + 1, (const uchar*)key, len+1, wkey_part, - &wkey.key_parts_len)) { - WSREP_WARN("key prepare failed for cascaded FK: %s", - (wsrep_thd_query(thd)) ? - wsrep_thd_query(thd) : "void"); + &wkey.key_parts_num)) { + WSREP_WARN("key prepare failed for cascaded FK: %s", + (wsrep_thd_query(thd)) ? + wsrep_thd_query(thd) : "void"); return DB_ERROR; } rcode = (int)wsrep->append_key( wsrep, - wsrep_trx_handle(thd, trx), + wsrep_ws_handle(thd, trx), &wkey, - 1, - shared); + 1, + shared ? WSREP_KEY_SHARED : WSREP_KEY_EXCLUSIVE, + copy); if (rcode) { DBUG_PRINT("wsrep", ("row key failed: %lu", rcode)); - WSREP_ERROR("Appending cascaded fk row key failed: %s, %lu", - (wsrep_thd_query(thd)) ? - wsrep_thd_query(thd) : "void", rcode); + WSREP_ERROR("Appending cascaded fk row key failed: %s, %lu", + (wsrep_thd_query(thd)) ? + wsrep_thd_query(thd) : "void", rcode); return DB_ERROR; } @@ -7352,6 +7354,7 @@ wsrep_append_key( ) { DBUG_ENTER("wsrep_append_key"); + bool const copy = true; #ifdef WSREP_DEBUG_PRINT fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s ", (shared) ? "Shared" : "Exclusive", @@ -7362,52 +7365,37 @@ wsrep_append_key( } fprintf(stderr, "\n"); #endif - wsrep_key_part_t wkey_part[3]; + wsrep_buf_t wkey_part[3]; wsrep_key_t wkey = {wkey_part, 3}; if (!wsrep_prepare_key_for_innodb( (const uchar*)table_share->table_cache_key.str, table_share->table_cache_key.length, (const uchar*)key, key_len, wkey_part, - &wkey.key_parts_len)) { - WSREP_WARN("key prepare failed for: %s", - (wsrep_thd_query(thd)) ? - wsrep_thd_query(thd) : "void"); + &wkey.key_parts_num)) { + WSREP_WARN("key prepare failed for: %s", + (wsrep_thd_query(thd)) ? + wsrep_thd_query(thd) : "void"); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } int rcode = (int)wsrep->append_key( wsrep, - wsrep_trx_handle(thd, trx), + wsrep_ws_handle(thd, trx), &wkey, 1, - shared); + shared ? WSREP_KEY_SHARED : WSREP_KEY_EXCLUSIVE, + copy); if (rcode) { DBUG_PRINT("wsrep", ("row key failed: %d", rcode)); - WSREP_WARN("Appending row key failed: %s, %d", - (wsrep_thd_query(thd)) ? - wsrep_thd_query(thd) : "void", rcode); + WSREP_WARN("Appending row key failed: %s, %d", + (wsrep_thd_query(thd)) ? + wsrep_thd_query(thd) : "void", rcode); DBUG_RETURN(rcode); } DBUG_RETURN(0); } -ibool -wsrep_is_cascding_foreign_key_parent( - dict_table_t* table, /*!< in: InnoDB table */ - dict_index_t* index /*!< in: InnoDB index */ -) { - // return referenced_by_foreign_key(); - dict_foreign_t* fk = dict_table_get_referenced_constraint(table, index); - if (fk && - (fk->type & DICT_FOREIGN_ON_UPDATE_CASCADE || - fk->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) - ) { - return TRUE; - } - return FALSE; -} - int ha_innobase::wsrep_append_keys( /*==================*/ @@ -7455,19 +7443,30 @@ ha_innobase::wsrep_append_keys( ut_a(table->s->keys <= 256); uint i; for (i=0; i<table->s->keys; ++i) { - uint len; - char keyval0[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; - char keyval1[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; - char *key0 = &keyval0[1]; - char *key1 = &keyval1[1]; - KEY *key_info = table->key_info + i; - ibool is_null; + uint len; + char keyval0[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; + char keyval1[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; + char* key0 = &keyval0[1]; + char* key1 = &keyval1[1]; + KEY* key_info = table->key_info + i; + ibool is_null; + + dict_index_t* idx = innobase_get_index(i); + dict_table_t* tab = (idx) ? idx->table : NULL; keyval0[0] = (char)i; keyval1[0] = (char)i; + if (!tab) { + WSREP_WARN("MySQL-InnoDB key mismatch %s %s", + table->s->table_name.str, + key_info->name); + } if (key_info->flags & HA_NOSAME || - referenced_by_foreign_key()) { + ((tab && + dict_table_get_referenced_constraint(tab, idx)) || + (!tab && referenced_by_foreign_key()))) { + if (key_info->flags & HA_NOSAME || shared) key_appended = true; @@ -12822,7 +12821,7 @@ wsrep_fake_trx_id( trx_id_t trx_id = trx_sys_get_new_trx_id(); mutex_exit(&kernel_mutex); - (void *)wsrep_trx_handle_for_id(wsrep_thd_trx_handle(thd), trx_id); + (void *)wsrep_ws_handle_for_trx(wsrep_thd_ws_handle(thd), trx_id); } #endif /* WITH_WSREP */ diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index bb12eed8c9f..c00fef579b0 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -308,7 +308,7 @@ extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd); extern "C" const char * wsrep_thd_exec_mode_str(THD *thd); extern "C" const char * wsrep_thd_conflict_state_str(THD *thd); extern "C" const char * wsrep_thd_query_state_str(THD *thd); -extern "C" wsrep_trx_handle_t* wsrep_thd_trx_handle(THD *thd); +extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd); extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode); extern "C" void wsrep_thd_set_query_state( diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index 6e762f65679..c500bf44ffa 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -1742,7 +1742,7 @@ lock_t* lock_rec_create( /*============*/ #ifdef WITH_WSREP - lock_t* c_lock, /* conflicting lock */ + lock_t* c_lock, /* conflicting lock */ #endif ulint type_mode,/*!< in: lock mode and wait flag, type is ignored and @@ -1810,7 +1810,7 @@ lock_rec_create( #ifdef WITH_WSREP if (c_lock && wsrep_thd_is_brute_force(trx->mysql_thd)) { - lock_t *hash = c_lock->hash; + lock_t *hash = c_lock->hash; lock_t *prev = NULL; while (hash && @@ -1829,7 +1829,7 @@ lock_rec_create( * delayed conflict resolution '...kill_one_trx' was not called, * if victim was waiting for some other lock */ - if (c_lock && c_lock->trx->que_state == TRX_QUE_LOCK_WAIT) { + if (c_lock->trx->que_state == TRX_QUE_LOCK_WAIT) { c_lock->trx->was_chosen_as_deadlock_victim = TRUE; if (wsrep_debug && c_lock->trx->wait_lock != c_lock) { @@ -1851,8 +1851,8 @@ lock_rec_create( } if (wsrep_debug) fprintf( - stderr, - "WSREP: c_lock canceled %llu\n", + stderr, + "WSREP: c_lock canceled %llu\n", (ulonglong) c_lock->trx->id); /* have to bail out here to avoid lock_set_lock... */ @@ -1865,7 +1865,7 @@ lock_rec_create( #else HASH_INSERT(lock_t, hash, lock_sys->rec_hash, lock_rec_fold(space, page_no), lock); -#endif +#endif /* WITH_WSREP */ if (lock_is_wait_not_by_other(type_mode)) { lock_set_lock_and_trx_wait(lock, trx); @@ -1886,7 +1886,7 @@ enum db_err lock_rec_enqueue_waiting( /*=====================*/ #ifdef WITH_WSREP - lock_t* c_lock, /* conflicting lock */ + lock_t* c_lock, /* conflicting lock */ #endif ulint type_mode,/*!< in: lock mode this transaction is requesting: @@ -2231,7 +2231,7 @@ lock_rec_lock_slow( { trx_t* trx; #ifdef WITH_WSREP - lock_t *c_lock= 0; + lock_t* c_lock = NULL; #endif lock_t* lock; @@ -2281,10 +2281,10 @@ lock_rec_lock_slow( #ifdef WITH_WSREP } else if ((c_lock = lock_rec_other_has_conflicting( - mode, block, heap_no, trx))) { + mode, block, heap_no, trx))) { #else } else if (lock_rec_other_has_conflicting(mode, block, heap_no, trx)) { -#endif +#endif /* WITH_WSREP */ /* If another transaction has a non-gap conflicting request in the queue, as this transaction does not have a lock strong @@ -2293,12 +2293,15 @@ lock_rec_lock_slow( ut_ad(lock == NULL); enqueue_waiting: #ifdef WITH_WSREP - return(lock_rec_enqueue_waiting(c_lock,mode, block, heap_no, + /* c_lock is NULL here if jump to enqueue_waiting happened + but it's ok because lock is not NULL in that case and c_lock + is not used. */ + return(lock_rec_enqueue_waiting(c_lock, mode, block, heap_no, lock, index, thr)); #else return(lock_rec_enqueue_waiting(mode, block, heap_no, lock, index, thr)); -#endif +#endif /* WITH_WSREP */ } else if (!impl) { /* Set the requested lock on the record */ @@ -3961,7 +3964,8 @@ lock_table_create( if (c_lock && c_lock->trx->que_state == TRX_QUE_LOCK_WAIT) { if (wsrep_debug) { - fprintf(stderr, "WSREP: table c_lock in wait: %llu new loc: %llu\n", + fprintf(stderr, + "WSREP: table c_lock in wait: %llu new loc: %llu\n", (ulonglong) c_lock->trx->id, lock->trx->id); } @@ -5603,7 +5607,7 @@ lock_rec_insert_check_and_lock( | LOCK_INSERT_INTENTION, block, next_rec_heap_no, NULL, index, thr); -#endif +#endif /* WITH_WSREP */ } else { err = DB_SUCCESS; } |