diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2016-12-30 08:56:13 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2016-12-30 08:56:13 +0200 |
commit | 970f17cbfc8825a39d10a6dec0bb7d8c432a9b3e (patch) | |
tree | 2f285ed9e12c27a63e9fb99012ecfc5dca0a3929 /storage/innobase | |
parent | 341c375d4bddf0e5c381954606ca18be3b8c55e0 (diff) | |
parent | 23cc1be270c7304963643947d8e5ab88f4e312ee (diff) | |
download | mariadb-git-970f17cbfc8825a39d10a6dec0bb7d8c432a9b3e.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'storage/innobase')
-rw-r--r-- | storage/innobase/api/api0misc.cc | 4 | ||||
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 81 | ||||
-rw-r--r-- | storage/innobase/include/srv0srv.h | 4 | ||||
-rw-r--r-- | storage/innobase/include/srv0start.h | 2 | ||||
-rw-r--r-- | storage/innobase/os/os0file.cc | 20 | ||||
-rw-r--r-- | storage/innobase/os/os0thread.cc | 4 | ||||
-rw-r--r-- | storage/innobase/srv/srv0srv.cc | 16 | ||||
-rw-r--r-- | storage/innobase/srv/srv0start.cc | 17 |
8 files changed, 78 insertions, 70 deletions
diff --git a/storage/innobase/api/api0misc.cc b/storage/innobase/api/api0misc.cc index 3864e4b9a7f..b510f292a35 100644 --- a/storage/innobase/api/api0misc.cc +++ b/storage/innobase/api/api0misc.cc @@ -113,10 +113,6 @@ handle_new_error: trx_rollback_for_mysql(trx); break; - case DB_MUST_GET_MORE_FILE_SPACE: - - ut_error; - case DB_CORRUPTION: case DB_FOREIGN_EXCEED_MAX_CASCADE: break; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index e1e97fc6e64..972fc3d4889 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -6330,11 +6330,13 @@ fil_iterate( for (offset = iter.start; offset < iter.end; offset += n_bytes) { - byte* io_buffer = iter.io_buffer; + byte* io_buffer = iter.io_buffer; + const bool row_compressed + = callback.get_page_size().is_compressed(); block->frame = io_buffer; - if (callback.get_page_size().is_compressed()) { + if (row_compressed) { page_zip_des_init(&block->page.zip); page_zip_set_size(&block->page.zip, iter.page_size); @@ -6406,9 +6408,11 @@ fil_iterate( bool decrypted = false; for (ulint i = 0; i < n_pages_read; ++i) { - ulint size = iter.page_size; - byte* src = (readptr + (i * size)); - byte* dst = (io_buffer + (i * size)); + ulint size = iter.page_size; + dberr_t err = DB_SUCCESS; + byte* src = readptr + (i * size); + byte* dst = io_buffer + (i * size); + bool frame_changed = false; ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); @@ -6432,9 +6436,12 @@ fil_iterate( if (decrypted) { updated = true; + } else if (!page_compressed + && !row_compressed) { + block->frame = src; + frame_changed = true; } else { - /* TODO: remove unnecessary memcpy's */ - memcpy(dst, src, iter.page_size); + memcpy(dst, src, size); } } @@ -6460,7 +6467,45 @@ fil_iterate( buf_block_set_state(block, BUF_BLOCK_NOT_USED); buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE); - src = (io_buffer + (i * size)); + /* If tablespace is encrypted we use additional + temporary scratch area where pages are read + for decrypting readptr == crypt_io_buffer != io_buffer. + + Destination for decryption is a buffer pool block + block->frame == dst == io_buffer that is updated. + Pages that did not require decryption even when + tablespace is marked as encrypted are not copied + instead block->frame is set to src == readptr. + + For encryption we again use temporary scratch area + writeptr != io_buffer == dst + that is then written to the tablespace + + (1) For normal tables io_buffer == dst == writeptr + (2) For only page compressed tables + io_buffer == dst == writeptr + (3) For encrypted (and page compressed) + readptr != io_buffer == dst != writeptr + */ + + ut_ad(!encrypted && !page_compressed ? + src == dst && dst == writeptr + (i * size):1); + ut_ad(page_compressed && !encrypted ? + src == dst && dst == writeptr + (i * size):1); + ut_ad(encrypted ? + src != dst && dst != writeptr + (i * size):1); + + if (encrypted) { + memcpy(writeptr + (i * size), + row_compressed ? block->page.zip.data : + block->frame, size); + } + + if (frame_changed) { + block->frame = dst; + } + + src = io_buffer + (i * size); if (page_compressed) { ulint len = 0; @@ -6481,7 +6526,7 @@ fil_iterate( write it back. Note that we should not encrypt the buffer that is in buffer pool. */ if (decrypted && encrypted) { - unsigned char *dest = (writeptr + (i * size)); + byte *dest = writeptr + (i * size); ulint space = mach_read_from_4( src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); ulint offset = mach_read_from_4(src + FIL_PAGE_OFFSET); @@ -6706,16 +6751,22 @@ fil_tablespace_iterate( iter.io_buffer = static_cast<byte*>( ut_align(io_buffer, UNIV_PAGE_SIZE)); - iter.crypt_io_buffer = iter.crypt_data - ? static_cast<byte*>( - ut_malloc_nokey(iter.n_io_buffers - * UNIV_PAGE_SIZE)) - : NULL; + void* crypt_io_buffer; + if (iter.crypt_data) { + crypt_io_buffer = static_cast<byte*>( + ut_malloc_nokey((2 + iter.n_io_buffers) + * UNIV_PAGE_SIZE)); + iter.crypt_io_buffer = static_cast<byte*>( + ut_align(crypt_io_buffer, + UNIV_PAGE_SIZE)); + } else { + crypt_io_buffer = NULL; + } err = fil_iterate(iter, block, callback); ut_free(io_buffer); - ut_free(iter.crypt_io_buffer); + ut_free(crypt_io_buffer); fil_space_destroy_crypt_data(&iter.crypt_data); } diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 056a6267347..5f68e435e93 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -955,10 +955,6 @@ void srv_purge_wakeup(void); /*==================*/ -/** Call exit(3) */ -void -srv_fatal_error(); - /** Check if tablespace is being truncated. (Ignore system-tablespace as we don't re-create the tablespace and so some of the action that are suppressed by this function diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index 708a90247e3..3b7b2375788 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -41,7 +41,7 @@ struct dict_table_t; fprintf(stderr, "innodb_force_recovery_crash=%lu\n", \ srv_force_recovery_crash); \ fflush(stderr); \ - _exit(3); \ + abort(); \ } \ } while (0) #endif /* DBUG_OFF */ diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index de9b347b4ec..8e9139026d0 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -5910,22 +5910,18 @@ os_file_get_last_error( return(os_file_get_last_error_low(report_all_errors, false)); } -/** Does error handling when a file operation fails. -Conditionally exits (calling srv_fatal_error()) based on should_exit value -and the error type, if should_exit is true then on_error_silent is ignored. +/** Handle errors for file operations. @param[in] name name of a file or NULL @param[in] operation operation -@param[in] should_exit call srv_fatal_error() on an unknown error, - if this parameter is true -@param[in] on_error_silent if true then don't print any message to the log - iff it is an unknown non-fatal error +@param[in] should_abort whether to abort on an unknown error +@param[in] on_error_silent whether to suppress reports of non-fatal errors @return true if we should retry the operation */ static MY_ATTRIBUTE((warn_unused_result)) bool os_file_handle_error_cond_exit( const char* name, const char* operation, - bool should_exit, + bool should_abort, bool on_error_silent) { ulint err; @@ -5986,17 +5982,17 @@ os_file_handle_error_cond_exit( is better to ignore on_error_silent and print an error message to the log. */ - if (should_exit || !on_error_silent) { + if (should_abort || !on_error_silent) { ib::error() << "File " << (name != NULL ? name : "(unknown)") << ": '" << operation << "'" " returned OS error " << err << "." - << (should_exit + << (should_abort ? " Cannot continue operation" : ""); } - if (should_exit) { - srv_fatal_error(); + if (should_abort) { + abort(); } } diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index edc9c8e9406..0ee789df7b9 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -153,9 +153,7 @@ os_thread_create_func( int ret = pthread_create(&new_thread_id, &attr, func, arg); - if (ret != 0) { - ib::fatal() << "pthread_create returned " << ret; - } + ut_a(ret == 0); pthread_attr_destroy(&attr); diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index d35b6421e5a..4ccbda71803 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -3230,19 +3230,3 @@ srv_was_tablespace_truncated(const fil_space_t* space) return(truncate_t::was_tablespace_truncated(space->id)); } - -/** Call exit(3) */ -void -srv_fatal_error() -{ - - ib::error() << "Cannot continue operation."; - - fflush(stderr); - - ut_d(innodb_calling_exit = true); - - srv_shutdown_all_bg_threads(); - - exit(3); -} diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index c549e458c7b..7c2f675645b 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -2221,21 +2221,8 @@ files_checked: if (err == DB_SUCCESS) { /* Initialize the change buffer. */ err = dict_boot(); - } - - if (err != DB_SUCCESS) { - - /* A tablespace was not found during recovery. The - user must force recovery. */ - - if (err == DB_TABLESPACE_NOT_FOUND) { - - srv_fatal_error(); - - ut_error; - } - - return(srv_init_abort(DB_ERROR)); + } else { + return(srv_init_abort(err)); } purge_queue = trx_sys_init_at_db_start(); |