diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-02-06 14:50:50 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-02-06 14:50:50 +0100 |
commit | 4771ae4b22d2bdef0aafc563570c71d4636a2493 (patch) | |
tree | d115bd7c68b1e6feab68ff6fcd547e0c86c79296 /storage/maria | |
parent | 60f51af755ea9d07c20a596ba21de184816fa265 (diff) | |
parent | 0c25e58db6b045df92c209d396031cac5b528bbf (diff) | |
download | mariadb-git-4771ae4b22d2bdef0aafc563570c71d4636a2493.tar.gz |
Merge branch 'github/10.1' into 10.2
Diffstat (limited to 'storage/maria')
-rw-r--r-- | storage/maria/ha_maria.cc | 7 | ||||
-rw-r--r-- | storage/maria/ma_blockrec.c | 20 | ||||
-rw-r--r-- | storage/maria/ma_page.c | 40 | ||||
-rw-r--r-- | storage/maria/ma_state.c | 24 | ||||
-rw-r--r-- | storage/maria/ma_state.h | 1 | ||||
-rw-r--r-- | storage/maria/ma_write.c | 2 | ||||
-rw-r--r-- | storage/maria/maria_def.h | 3 | ||||
-rw-r--r-- | storage/maria/unittest/ma_test_loghandler_multigroup-t.c | 6 | ||||
-rw-r--r-- | storage/maria/unittest/ma_test_loghandler_nologs-t.c | 2 |
9 files changed, 73 insertions, 32 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 0c642aa6c65..d45da38ab79 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2148,11 +2148,16 @@ void ha_maria::start_bulk_insert(ha_rows rows, uint flags) safety net for now, we don't remove the test of file->state->records, because there is uncertainty on what will happen during repair if the two states disagree. + + We also have to check in case of transactional tables that the + user has not used LOCK TABLE on the table twice. */ if ((file->state->records == 0) && (share->state.state.records == 0) && can_enable_indexes && (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES) && - (file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK)) + (file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK) && + (!share->have_versioning || !share->now_transactional || + file->used_tables->use_count == 1)) { /** @todo for a single-row INSERT SELECT, we will go into repair, which diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index b965f5db34b..c91ba8e23f6 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -6166,7 +6166,7 @@ my_bool write_hook_for_undo_row_insert(enum translog_record_type type /** - @brief Upates "records" and calls the generic UNDO hook + @brief Updates "records" and calls the generic UNDO hook @return Operation status, always 0 (success) */ @@ -6316,8 +6316,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, uchar *buff, *dir; uint result; MARIA_PINNED_PAGE page_link; - enum pagecache_page_lock unlock_method; - enum pagecache_page_pin unpin_method; + enum pagecache_page_lock lock_method; + enum pagecache_page_pin pin_method; my_off_t end_of_page; uint error; DBUG_ENTER("_ma_apply_redo_insert_row_head_or_tail"); @@ -6345,8 +6345,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, fill it entirely with zeroes, then the REDO will put correct data on it. */ - unlock_method= PAGECACHE_LOCK_WRITE; - unpin_method= PAGECACHE_PIN; + lock_method= PAGECACHE_LOCK_WRITE; + pin_method= PAGECACHE_PIN; DBUG_ASSERT(rownr == 0 && new_page); if (rownr != 0 || !new_page) @@ -6361,8 +6361,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, } else { - unlock_method= PAGECACHE_LOCK_LEFT_WRITELOCKED; - unpin_method= PAGECACHE_PIN_LEFT_PINNED; + lock_method= PAGECACHE_LOCK_LEFT_WRITELOCKED; + pin_method= PAGECACHE_PIN_LEFT_PINNED; share->pagecache->readwrite_flags&= ~MY_WME; buff= pagecache_read(share->pagecache, &info->dfile, @@ -6463,11 +6463,11 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, this group, for this page, would be skipped) and unpin then. */ result= 0; - if (unlock_method == PAGECACHE_LOCK_WRITE && + if (lock_method == PAGECACHE_LOCK_WRITE && pagecache_write(share->pagecache, &info->dfile, page, 0, buff, PAGECACHE_PLAIN_PAGE, - unlock_method, unpin_method, + lock_method, pin_method, PAGECACHE_WRITE_DELAY, &page_link.link, LSN_IMPOSSIBLE)) result= my_errno; @@ -6488,7 +6488,7 @@ crashed_file: _ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD); err: error= my_errno; - if (unlock_method == PAGECACHE_LOCK_LEFT_WRITELOCKED) + if (lock_method == PAGECACHE_LOCK_LEFT_WRITELOCKED) pagecache_unlock_by_link(share->pagecache, page_link.link, PAGECACHE_LOCK_WRITE_UNLOCK, PAGECACHE_UNPIN, LSN_IMPOSSIBLE, diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index c8901e6d736..0e83a89917d 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -224,17 +224,35 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, #endif page_cleanup(share, page); - res= pagecache_write(share->pagecache, - &share->kfile, - (pgcache_page_no_t) (page->pos / block_size), - level, buff, share->page_type, - lock, - lock == PAGECACHE_LOCK_LEFT_WRITELOCKED ? - PAGECACHE_PIN_LEFT_PINNED : - (lock == PAGECACHE_LOCK_WRITE_UNLOCK ? - PAGECACHE_UNPIN : PAGECACHE_PIN), - PAGECACHE_WRITE_DELAY, &page_link.link, - LSN_IMPOSSIBLE); + { + PAGECACHE_BLOCK_LINK **link; + enum pagecache_page_pin pin; + if (lock == PAGECACHE_LOCK_LEFT_WRITELOCKED) + { + pin= PAGECACHE_PIN_LEFT_PINNED; + link= &page_link.link; + } + else if (lock == PAGECACHE_LOCK_WRITE_UNLOCK) + { + pin= PAGECACHE_UNPIN; + /* + We unlock this page so link should be 0 to prevent it usage + even accidentally + */ + link= NULL; + } + else + { + pin= PAGECACHE_PIN; + link= &page_link.link; + } + res= pagecache_write(share->pagecache, + &share->kfile, + (pgcache_page_no_t) (page->pos / block_size), + level, buff, share->page_type, + lock, pin, PAGECACHE_WRITE_DELAY, link, + LSN_IMPOSSIBLE); + } if (lock == PAGECACHE_LOCK_WRITE) { diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 05bc8a8acb8..71e1e8a67a6 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -58,6 +58,7 @@ my_bool _ma_setup_live_state(MARIA_HA *info) MARIA_USED_TABLES *tables; MARIA_STATE_HISTORY *history; DBUG_ENTER("_ma_setup_live_state"); + DBUG_PRINT("enter", ("info: %p", info)); DBUG_ASSERT(share->lock_key_trees); @@ -110,6 +111,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info) end: info->state_start= &tables->state_start; info->state= &tables->state_current; + info->used_tables= tables; + tables->use_count++; /* Mark in transaction state if we are not using transid (versioning) @@ -118,6 +121,7 @@ end: */ tables->state_current.no_transid|= !(info->row_flag & ROW_FLAG_TRANSID); + DBUG_PRINT("exit", ("tables: %p info->state: %p", tables, info->state)); DBUG_RETURN(0); } @@ -241,9 +245,10 @@ void _ma_reset_state(MARIA_HA *info) DBUG_ENTER("_ma_reset_state"); /* Always true if share->now_transactional is set */ - if (history) + if (history && share->have_versioning) { MARIA_STATE_HISTORY *next; + DBUG_PRINT("info", ("resetting history")); /* Set the current history to current state */ share->state_history->state= share->state.state; @@ -255,7 +260,7 @@ void _ma_reset_state(MARIA_HA *info) my_free(history); } share->state_history->next= 0; - share->state_history->trid= 0; /* Visibile for all */ + share->state_history->trid= 0; /* Visible for all */ } DBUG_VOID_RETURN; } @@ -597,7 +602,7 @@ void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn) SYNOPSIS _ma_get_status() - param Pointer to Myisam handler + param Pointer to Aria handler concurrent_insert Set to 1 if we are going to do concurrent inserts (THR_WRITE_CONCURRENT_INSERT was used) */ @@ -627,6 +632,8 @@ void _ma_block_get_status(void* param, my_bool concurrent_insert) my_bool _ma_block_start_trans(void* param) { MARIA_HA *info=(MARIA_HA*) param; + DBUG_ENTER("_ma_block_start_trans"); + if (info->s->lock_key_trees) { /* @@ -634,7 +641,7 @@ my_bool _ma_block_start_trans(void* param) out of memory conditions) TODO: Fix this by having one extra state pre-allocated */ - return _ma_setup_live_state(info); + DBUG_RETURN(_ma_setup_live_state(info)); } else { @@ -663,9 +670,9 @@ my_bool _ma_block_start_trans(void* param) Assume for now that this doesn't fail (It can only fail in out of memory conditions) */ - return maria_create_trn_hook(info) != 0; + DBUG_RETURN(maria_create_trn_hook(info) != 0); } - return 0; + DBUG_RETURN(0); } @@ -697,7 +704,7 @@ my_bool _ma_block_check_status(void *param __attribute__((unused))) my_bool _ma_block_start_trans_no_versioning(void* param) { MARIA_HA *info=(MARIA_HA*) param; - DBUG_ENTER("_ma_block_get_status_no_version"); + DBUG_ENTER("_ma_block_start_trans_no_versioning"); DBUG_ASSERT(info->s->base.born_transactional && !info->s->lock_key_trees); info->state->changed= 0; /* from _ma_reset_update_flag() */ @@ -722,6 +729,8 @@ my_bool _ma_block_start_trans_no_versioning(void* param) void maria_versioning(MARIA_HA *info, my_bool versioning) { MARIA_SHARE *share= info->s; + DBUG_ENTER("maria_versioning"); + /* For now, this is a hack */ if (share->have_versioning) { @@ -738,6 +747,7 @@ void maria_versioning(MARIA_HA *info, my_bool versioning) info->state= &share->state.state; /* Change global values by default */ info->state_start= info->state; /* Initial values */ } + DBUG_VOID_RETURN; } diff --git a/storage/maria/ma_state.h b/storage/maria/ma_state.h index 5ff6dc26337..a86aada94fd 100644 --- a/storage/maria/ma_state.h +++ b/storage/maria/ma_state.h @@ -34,6 +34,7 @@ typedef struct st_used_tables { struct st_maria_share *share; MARIA_STATUS_INFO state_current; MARIA_STATUS_INFO state_start; + uint use_count; } MARIA_USED_TABLES; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index ffebb8c0ac9..66bf77e0a80 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -341,7 +341,7 @@ err: for (j=0 ; j < share->base.keys ; j++) maria_flush_bulk_insert(info, j); } - info->errkey= (int) i; + info->errkey= i < share->base.keys ? (int) i : -1; /* We delete keys in the reverse order of insertion. This is the order that a rollback would do and is important for CLR_ENDs generated by diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index cc100b3706c..a35403fff39 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -600,6 +600,7 @@ struct st_maria_handler struct st_ma_transaction *trn; /* Pointer to active transaction */ MARIA_STATUS_INFO *state, state_save; MARIA_STATUS_INFO *state_start; /* State at start of transaction */ + MARIA_USED_TABLES *used_tables; MARIA_ROW cur_row; /* The active row that we just read */ MARIA_ROW new_row; /* Storage for a row during update */ MARIA_KEY last_key; /* Last found key */ @@ -1182,7 +1183,7 @@ extern ulonglong transid_get_packed(MARIA_SHARE *share, const uchar *from); #ifdef IDENTICAL_PAGES_AFTER_RECOVERY void page_cleanup(MARIA_SHARE *share, MARIA_PAGE *page) #else -#define page_cleanup(A,B) while (0) +#define page_cleanup(A,B) do { } while (0) #endif extern MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr, diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c index 69bc2f70f8c..cffe188e855 100644 --- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c @@ -233,7 +233,7 @@ int main(int argc __attribute__((unused)), char *argv[]) 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 }; - uchar *long_buffer= malloc(LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); + uchar *long_buffer; char **default_argv; PAGECACHE pagecache; LSN lsn, lsn_base, first_lsn; @@ -255,6 +255,7 @@ int main(int argc __attribute__((unused)), char *argv[]) } #endif + long_buffer= malloc(LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); load_defaults("my", load_default_groups, &argc, &argv); default_argv= argv; get_options(&argc, &argv); @@ -758,9 +759,12 @@ err: if (maria_log_remove(maria_data_root)) exit(1); + free(long_buffer); + my_uuid_end(); my_free_open_file_info(); my_end(0); + return (MY_TEST(exit_status())); } diff --git a/storage/maria/unittest/ma_test_loghandler_nologs-t.c b/storage/maria/unittest/ma_test_loghandler_nologs-t.c index a6ccfd754de..310345f0885 100644 --- a/storage/maria/unittest/ma_test_loghandler_nologs-t.c +++ b/storage/maria/unittest/ma_test_loghandler_nologs-t.c @@ -191,6 +191,8 @@ int main(int argc __attribute__((unused)), char *argv[]) if (maria_log_remove(maria_data_root)) exit(1); + free(long_buffer); + my_uuid_end(); my_free_open_file_info(); my_end(0); |