diff --git a/cmake/build_depends.cmake b/cmake/build_depends.cmake index 0d17c22cf98..333df580200 100644 --- a/cmake/build_depends.cmake +++ b/cmake/build_depends.cmake @@ -16,6 +16,11 @@ IF(RPM) ENDIF() ENDMACRO() + # FindBoost.cmake doesn't leave any trace, do it here + IF (Boost_INCLUDE_DIR) + FIND_FILE(Boost_config_hpp boost/config.hpp PATHS ${Boost_INCLUDE_DIR}) + ENDIF() + GET_CMAKE_PROPERTY(ALL_VARS CACHE_VARIABLES) FOREACH (V ${ALL_VARS}) GET_PROPERTY(H CACHE ${V} PROPERTY HELPSTRING) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 338cf22a7de..6b9a466d443 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -221,8 +221,6 @@ const char *defaults_group = "mysqld"; #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ #define HA_INNOBASE_RANGE_COUNT 100 -ulong innobase_large_page_size = 0; - /* The default values for the following, type long or longlong, start-up parameters are declared in mysqld.cc: */ @@ -242,7 +240,6 @@ char* innobase_data_home_dir; char* innobase_data_file_path; my_bool innobase_use_doublewrite; -my_bool innobase_use_large_pages; my_bool innobase_file_per_table; my_bool innobase_locks_unsafe_for_binlog; my_bool innobase_rollback_on_timeout; @@ -1915,8 +1912,6 @@ static bool innodb_init_param() srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; - os_use_large_pages = (ibool) innobase_use_large_pages; - os_large_page_size = (ulint) innobase_large_page_size; row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; srv_file_per_table = (my_bool) innobase_file_per_table; @@ -3985,9 +3980,7 @@ static bool xtrabackup_backup_low() /** Implement --backup @return whether the operation succeeded */ -static -bool -xtrabackup_backup_func() +static bool xtrabackup_backup_func() { MY_STAT stat_info; uint i; @@ -4120,38 +4113,25 @@ fail: log_mutex_enter(); +reread_log_header: dberr_t err = recv_find_max_checkpoint(&max_cp_field); if (err != DB_SUCCESS) { -log_fail: + msg("Error: cannot read redo log header"); log_mutex_exit(); goto fail; } if (log_sys.log.format == 0) { -old_format: - msg("Error: cannot process redo log" - " before MariaDB 10.2.2"); + msg("Error: cannot process redo log before MariaDB 10.2.2"); log_mutex_exit(); - goto log_fail; + goto fail; } const byte* buf = log_sys.checkpoint_buf; - -reread_log_header: checkpoint_lsn_start = log_sys.log.lsn; checkpoint_no_start = log_sys.next_checkpoint_no; - err = recv_find_max_checkpoint(&max_cp_field); - - if (err != DB_SUCCESS) { - goto log_fail; - } - - if (log_sys.log.format == 0) { - goto old_format; - } - log_header_read(max_cp_field); if (checkpoint_no_start != mach_read_from_8(buf + LOG_CHECKPOINT_NO)) { @@ -4197,6 +4177,12 @@ reread_log_header: mach_write_to_8(log_hdr + LOG_CHECKPOINT_OFFSET, (checkpoint_lsn_start & (OS_FILE_LOG_BLOCK_SIZE - 1)) | LOG_FILE_HDR_SIZE); + /* The least significant bits of LOG_CHECKPOINT_OFFSET must be + stored correctly in the copy of the ib_logfile. The most significant + bits, which identify the start offset of the log block in the file, + we did choose freely, as LOG_FILE_HDR_SIZE. */ + ut_ad(!((log_sys.log.lsn ^ checkpoint_lsn_start) + & (OS_FILE_LOG_BLOCK_SIZE - 1))); log_block_set_checksum(log_hdr, log_block_calc_checksum_crc32(log_hdr)); /* Write checkpoint page 1 and two empty log pages before the diff --git a/mysql-test/suite/innodb/t/undo_truncate_recover.test b/mysql-test/suite/innodb/t/undo_truncate_recover.test index c3fa698ff13..81db3086711 100644 --- a/mysql-test/suite/innodb/t/undo_truncate_recover.test +++ b/mysql-test/suite/innodb/t/undo_truncate_recover.test @@ -2,18 +2,14 @@ # WL#6965: Truncate UNDO logs. # +--source include/big_test.inc # With larger innodb_page_size, the undo log tablespaces do not grow enough. --source include/innodb_page_size_small.inc --source include/have_innodb.inc --source include/have_debug.inc --source include/have_undo_tablespaces.inc - -# Valgrind would complain about memory leaks when we crash on purpose. ---source include/not_valgrind.inc -# Embedded server does not support crashing +# Tests with embedded server do not support restarting --source include/not_embedded.inc -# Avoid CrashReporter popup on Mac ---source include/not_crashrep.inc SET GLOBAL innodb_undo_logs = 4; SET GLOBAL innodb_undo_log_truncate = 1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a28d5807ce4..c7ec0dd99ef 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6286,7 +6286,7 @@ drop_create_field: Key_part_spec *kp; if ((kp= part_it++)) chkname= kp->field_name.str; - if (keyname == NULL) + if (chkname == NULL) continue; } if (key->type == chk_key->type && diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 10e8dfc6904..67b5af6c63d 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -714,159 +714,57 @@ btr_page_free_for_ibuf( mtr)); } -/**************************************************************//** -Frees a file page used in an index tree. Can be used also to (BLOB) -external storage pages. */ -void -btr_page_free_low( -/*==============*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: block to be freed, x-latched */ - ulint level, /*!< in: page level (ULINT_UNDEFINED=BLOB) */ - bool blob, /*!< in: blob page */ - mtr_t* mtr) /*!< in: mtr */ +/** Free an index page. +@param[in,out] index index tree +@param[in,out] block block to be freed +@param[in,out] mtr mini-transaction +@param[in] blob whether this is freeing a BLOB page */ +void btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr, + bool blob) { - fseg_header_t* seg_header; - page_t* root; - ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); +#ifdef BTR_CUR_HASH_ADAPT + ut_ad(!block->index || !blob); + ut_ad(!block->index || page_is_leaf(block->frame)); +#endif + ut_ad(index->table->space_id == block->page.id.space()); + /* The root page is freed by btr_free_root(). */ + ut_ad(block->page.id.page_no() != index->page); + ut_ad(mtr->is_named_space(index->table->space)); + /* The page gets invalid for optimistic searches: increment the frame modify clock */ buf_block_modify_clock_inc(block); - if (blob) { - ut_a(level == 0); - } - - bool scrub = srv_immediate_scrub_data_uncompressed; - /* scrub page */ - if (scrub && blob) { - /* blob page: scrub entire page */ - // TODO(jonaso): scrub only what is actually needed - page_t* page = buf_block_get_frame(block); - memset(page + PAGE_HEADER, 0, - srv_page_size - PAGE_HEADER); -#ifdef UNIV_DEBUG_SCRUBBING - fprintf(stderr, - "btr_page_free_low: scrub blob page %lu/%lu\n", - buf_block_get_space(block), - buf_block_get_page_no(block)); -#endif /* UNIV_DEBUG_SCRUBBING */ - } else if (scrub) { - /* scrub records on page */ - - /* TODO(jonaso): in theory we could clear full page - * but, since page still remains in buffer pool, and - * gets flushed etc. Lots of routines validates consistency - * of it. And in order to remain structurally consistent - * we clear each record by it own - * - * NOTE: The TODO below mentions removing page from buffer pool - * and removing redo entries, once that is done, clearing full - * pages should be possible - */ - uint cnt = 0; - ulint bytes = 0; - page_t* page = buf_block_get_frame(block); - mem_heap_t* heap = NULL; - ulint* offsets = NULL; - rec_t* rec = page_rec_get_next(page_get_infimum_rec(page)); - while (!page_rec_is_supremum(rec)) { - offsets = rec_get_offsets(rec, index, offsets, - page_is_leaf(page), - ULINT_UNDEFINED, - &heap); - ulint size = rec_offs_data_size(offsets); - memset(rec, 0, size); - rec = page_rec_get_next(rec); - cnt++; - bytes += size; - } -#ifdef UNIV_DEBUG_SCRUBBING - fprintf(stderr, - "btr_page_free_low: scrub %lu/%lu - " - "%u records " ULINTPF " bytes\n", - buf_block_get_space(block), - buf_block_get_page_no(block), - cnt, bytes); -#endif /* UNIV_DEBUG_SCRUBBING */ - if (heap) { - mem_heap_free(heap); - } - } - -#ifdef UNIV_DEBUG_SCRUBBING - if (scrub == false) { - fprintf(stderr, - "btr_page_free_low %lu/%lu blob: %u\n", - buf_block_get_space(block), - buf_block_get_page_no(block), - blob); - } -#endif /* UNIV_DEBUG_SCRUBBING */ - if (dict_index_is_ibuf(index)) { - btr_page_free_for_ibuf(index, block, mtr); - return; } - root = btr_root_get(index, mtr); - - if (level == 0 || level == ULINT_UNDEFINED) { - seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - } else { - seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP; - } - -#ifdef UNIV_GIS_DEBUG - if (dict_index_is_spatial(index)) { - fprintf(stderr, "GIS_DIAG: Freed %ld\n", - (long) block->page.id.page_no()); - } -#endif - - if (scrub) { - /** - * Reset page type so that scrub thread won't try to scrub it - */ - mlog_write_ulint(buf_block_get_frame(block) + FIL_PAGE_TYPE, - FIL_PAGE_TYPE_ALLOCATED, MLOG_2BYTES, mtr); - } - + /* TODO: Discard any operations for block from mtr->log. + The page will be freed, so previous changes to it by this + mini-transaction should not matter. */ + page_t* root = btr_root_get(index, mtr); + fseg_header_t* seg_header = &root[blob || page_is_leaf(block->frame) + ? PAGE_HEADER + PAGE_BTR_SEG_LEAF + : PAGE_HEADER + PAGE_BTR_SEG_TOP]; fseg_free_page(seg_header, block->page.id.space(), block->page.id.page_no(), - level != ULINT_UNDEFINED, mtr); + block->index != NULL, mtr); /* The page was marked free in the allocation bitmap, but it - should remain buffer-fixed until mtr_commit(mtr) or until it + should remain exclusively latched until mtr_t::commit() or until it is explicitly freed from the mini-transaction. */ ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); - /* TODO: Discard any operations on the page from the redo log - and remove the block from the flush list and the buffer pool. - This would free up buffer pool earlier and reduce writes to - both the tablespace and the redo log. */ -} -/**************************************************************//** -Frees a file page used in an index tree. NOTE: cannot free field external -storage pages because the page must contain info on its level. */ -void -btr_page_free( -/*==========*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: block to be freed, x-latched */ - mtr_t* mtr) /*!< in: mtr */ -{ - const page_t* page = buf_block_get_frame(block); - ulint level = btr_page_get_level(page); - - ut_ad(fil_page_index_page_check(block->frame)); - ut_ad(level != ULINT_UNDEFINED); - btr_page_free_low(index, block, level, false, mtr); + if (srv_immediate_scrub_data_uncompressed) { + /* In MDEV-15528 this call must be removed, and we should + zero out the page after the redo log for this mini-transaction + has been durably written. */ + fsp_init_file_page(index->table->space, block, mtr); + } } /**************************************************************//** diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 9702ae9b4ad..7c14246f22f 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -1032,7 +1032,7 @@ BtrBulk::finish(dberr_t err) root_page_bulk.copyIn(first_rec); /* Remove last page. */ - btr_page_free_low(m_index, last_block, m_root_level, false, &mtr); + btr_page_free(m_index, last_block, &mtr); /* Do not flush the last page. */ last_block->page.flush_observer = NULL; diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 1b18aed1f45..25ed6fc1654 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -7911,8 +7911,7 @@ btr_free_externally_stored_field( } next_page_no = mach_read_from_4(page + FIL_PAGE_NEXT); - btr_page_free_low(index, ext_block, 0, - true, &mtr); + btr_page_free(index, ext_block, &mtr, true); if (page_zip != NULL) { mach_write_to_4(field_ref + BTR_EXTERN_PAGE_NO, @@ -7938,12 +7937,7 @@ btr_free_externally_stored_field( next_page_no = mach_read_from_4( page + FIL_PAGE_DATA + BTR_BLOB_HDR_NEXT_PAGE_NO); - - /* We must supply the page level (= 0) as an argument - because we did not store it on the page (we save the - space overhead from an index page header. */ - btr_page_free_low(index, ext_block, 0, - true, &mtr); + btr_page_free(index, ext_block, &mtr, true); mlog_write_ulint(field_ref + BTR_EXTERN_PAGE_NO, next_page_no, diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 2d5c0ddc3ca..81eeba2b1ad 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1606,7 +1606,7 @@ buf_chunk_init( chunk->blocks = (buf_block_t*) chunk->mem; /* Align a pointer to the first frame. Note that when - os_large_page_size is smaller than srv_page_size, + opt_large_page_size is smaller than srv_page_size, we may allocate one fewer block than requested. When it is bigger, we may allocate more blocks than requested. */ diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index d300212a56c..30473dd563e 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -598,59 +598,34 @@ void fsp_apply_init_file_page(buf_block_t* block) #ifdef UNIV_DEBUG /** Assert that the mini-transaction is compatible with updating an allocation bitmap page. -@param[in] id tablespace identifier @param[in] mtr mini-transaction */ -static -void -fsp_space_modify_check( - const fil_space_t* space, - const mtr_t* mtr) +void fil_space_t::modify_check(const mtr_t& mtr) const { - switch (mtr->get_log_mode()) { + switch (mtr.get_log_mode()) { case MTR_LOG_SHORT_INSERTS: case MTR_LOG_NONE: /* These modes are only allowed within a non-bitmap page when there is a higher-level redo log record written. */ - ut_ad(space->purpose == FIL_TYPE_TABLESPACE - || space->purpose == FIL_TYPE_TEMPORARY); + ut_ad(purpose == FIL_TYPE_TABLESPACE + || purpose == FIL_TYPE_TEMPORARY); break; case MTR_LOG_NO_REDO: - ut_ad(space->purpose == FIL_TYPE_TEMPORARY - || space->purpose == FIL_TYPE_IMPORT - || my_atomic_loadlint(&space->redo_skipped_count) - || srv_is_tablespace_truncated(space->id)); + ut_ad(purpose == FIL_TYPE_TEMPORARY + || purpose == FIL_TYPE_IMPORT + || my_atomic_loadlint(&redo_skipped_count) + || is_being_truncated + || srv_is_tablespace_truncated(id)); return; case MTR_LOG_ALL: - /* We may only write redo log for a persistent tablespace. */ - ut_ad(space->purpose == FIL_TYPE_TABLESPACE); - ut_ad(mtr->is_named_space(space->id)); + /* We may only write redo log for a persistent + tablespace. */ + ut_ad(purpose == FIL_TYPE_TABLESPACE); + ut_ad(mtr.is_named_space(id)); return; } - ut_ad(0); + ut_ad(!"invalid log mode"); } -#endif /* UNIV_DEBUG */ - -/** Initialize a file page. -@param[in,out] block file page -@param[in,out] mtr mini-transaction */ -static void fsp_init_file_page(buf_block_t* block, mtr_t* mtr) -{ - fsp_apply_init_file_page(block); - mlog_write_initial_log_record(block->frame, MLOG_INIT_FILE_PAGE2, mtr); -} - -#ifdef UNIV_DEBUG -static -void -fsp_init_file_page(const fil_space_t* space, buf_block_t* block, mtr_t* mtr) -{ - ut_d(fsp_space_modify_check(space, mtr)); - ut_ad(space->id == block->page.id.space()); - fsp_init_file_page(block, mtr); -} -#else /* UNIV_DEBUG */ -# define fsp_init_file_page(space, block, mtr) fsp_init_file_page(block, mtr) #endif /**********************************************************************//** @@ -778,7 +753,7 @@ fsp_try_extend_data_file_with_pages( ulint size; ut_a(!is_system_tablespace(space->id)); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); size = mach_read_from_4(header + FSP_SIZE); ut_ad(size == space->size_in_header); @@ -810,7 +785,7 @@ fsp_try_extend_data_file(fil_space_t* space, fsp_header_t* header, mtr_t* mtr) "ran out of space. Please add another file or use" " 'autoextend' for the last file in setting"; - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); if (space->id == TRX_SYS_SPACE && !srv_sys_space.can_auto_extend_last_file()) { @@ -882,7 +857,7 @@ fsp_try_extend_data_file(fil_space_t* space, fsp_header_t* header, mtr_t* mtr) /* We ignore any fragments of a full megabyte when storing the size to the space header */ - space->size_in_header = ut_calc_align_down( + space->size_in_header = ut_2pow_round( space->size, (1024 * 1024) / page_size.physical()); mlog_write_ulint( @@ -973,7 +948,7 @@ fsp_fill_free_list( ulint i; ut_ad(page_offset(header) == FSP_HEADER_OFFSET); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); /* Check if we can fill free list from above the free list limit */ size = mach_read_from_4(header + FSP_SIZE); @@ -1296,7 +1271,7 @@ fsp_alloc_free_page( ulint free; const ulint space_id = space->id; - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); header = fsp_get_space_header(space, page_size, mtr); /* Get the hinted descriptor */ @@ -1402,7 +1377,7 @@ fsp_free_page( ulint frag_n_used; ut_ad(mtr); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); /* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */ @@ -1724,7 +1699,7 @@ fsp_free_seg_inode( page_t* page; fsp_header_t* space_header; - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); page = page_align(inode); @@ -1974,7 +1949,7 @@ fseg_create( mtr_x_lock(&space->latch, mtr); const page_size_t page_size(space->flags); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); if (page != 0) { block = buf_page_get(page_id_t(space->id, page), page_size, @@ -2153,7 +2128,7 @@ fseg_fill_free_list( ut_ad(inode && mtr); ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); reserved = fseg_n_reserved_pages_low(inode, &used, mtr); @@ -2221,7 +2196,7 @@ fseg_alloc_free_extent( ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); if (flst_get_len(inode + FSEG_FREE) > 0) { /* Segment free list is not empty, allocate from it */ @@ -2308,7 +2283,7 @@ fseg_alloc_free_page_low( seg_id = mach_read_from_8(seg_inode + FSEG_ID); ut_ad(seg_id); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); ut_ad(fil_page_get_type(page_align(seg_inode)) == FIL_PAGE_INODE); reserved = fseg_n_reserved_pages_low(seg_inode, &used, mtr); @@ -2849,7 +2824,7 @@ fseg_free_page_low( ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE)); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); #ifdef BTR_CUR_HASH_ADAPT /* Drop search system page hash index if the page is found in the pool and is hashed */ @@ -3045,7 +3020,7 @@ fseg_free_extent( ut_a(!memcmp(descr + XDES_ID, seg_inode + FSEG_ID, 8)); ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); - ut_d(fsp_space_modify_check(space, mtr)); + ut_d(space->modify_check(*mtr)); first_page_in_extent = page - (page % FSP_EXTENT_SIZE); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 9562d1d7462..8db3b72cee6 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4013,12 +4013,6 @@ static int innodb_init_params() innodb_log_checksums = innodb_log_checksums_func_update( NULL, innodb_log_checksums); -#ifdef HAVE_LINUX_LARGE_PAGES - if ((os_use_large_pages = my_use_large_pages)) { - os_large_page_size = opt_large_page_size; - } -#endif - row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 139e4add16c..2d69256f0e3 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -682,16 +682,6 @@ btr_page_alloc( for x-latching and initializing the page */ MY_ATTRIBUTE((warn_unused_result)); -/**************************************************************//** -Frees a file page used in an index tree. NOTE: cannot free field external -storage pages because the page must contain info on its level. */ -void -btr_page_free( -/*==========*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: block to be freed, x-latched */ - mtr_t* mtr) /*!< in: mtr */ - MY_ATTRIBUTE((nonnull)); /** Empty an index page (possibly the root page). @see btr_page_create(). @param[in,out] block page to be emptied @param[in,out] page_zip compressed page frame, or NULL @@ -717,18 +707,16 @@ btr_page_create( dict_index_t* index, /*!< in: index */ ulint level, /*!< in: the B-tree level of the page */ mtr_t* mtr); /*!< in: mtr */ -/**************************************************************//** -Frees a file page used in an index tree. Can be used also to BLOB -external storage pages. */ -void -btr_page_free_low( -/*==============*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: block to be freed, x-latched */ - ulint level, /*!< in: page level (ULINT_UNDEFINED=BLOB) */ - bool blob, /*!< in: blob page */ - mtr_t* mtr) /*!< in: mtr */ - MY_ATTRIBUTE((nonnull(1,2))); + +/** Free an index page. +@param[in,out] index index tree +@param[in,out] block block to be freed +@param[in,out] mtr mini-transaction +@param[in] blob whether this is freeing a BLOB page */ +MY_ATTRIBUTE((nonnull)) +void btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr, + bool blob = false); + /**************************************************************//** Gets the root node of a tree and x- or s-latches it. @return root page, x- or s-latched */ diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 8fedd962290..4ae303e9321 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -102,7 +102,7 @@ struct fil_space_t { ulint redo_skipped_count; /*!< reference count for operations who want to skip redo log in the file space in order - to make fsp_space_modify_check pass. + to make modify_check() pass. Uses my_atomic_loadlint() and friends. */ #endif fil_type_t purpose;/*!< purpose */ @@ -199,6 +199,12 @@ struct fil_space_t { fil_node_t* add(const char* name, pfs_os_file_t handle, ulint size, bool is_raw, bool atomic_write, ulint max_pages = ULINT_MAX); +#ifdef UNIV_DEBUG + /** Assert that the mini-transaction is compatible with + updating an allocation bitmap page. + @param[in] mtr mini-transaction */ + void modify_check(const mtr_t& mtr) const; +#endif /* UNIV_DEBUG */ /** Try to reserve free extents. @param[in] n_free_now current number of free extents diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index cdbcbd2c82e..b8952a5ee17 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -631,6 +631,26 @@ fsp_descr_page( @param[in,out] block buffer pool block */ void fsp_apply_init_file_page(buf_block_t* block); +/** Initialize a file page. +@param[in] space tablespace +@param[in,out] block file page +@param[in,out] mtr mini-transaction */ +inline void fsp_init_file_page( +#ifdef UNIV_DEBUG + const fil_space_t* space, +#endif + buf_block_t* block, mtr_t* mtr) +{ + ut_d(space->modify_check(*mtr)); + ut_ad(space->id == block->page.id.space()); + fsp_apply_init_file_page(block); + mlog_write_initial_log_record(block->frame, MLOG_INIT_FILE_PAGE2, mtr); +} + +#ifndef UNIV_DEBUG +# define fsp_init_file_page(space, block, mtr) fsp_init_file_page(block, mtr) +#endif + #ifdef UNIV_BTR_PRINT /*******************************************************************//** Writes info of a segment. */ diff --git a/storage/innobase/include/mem0mem.h b/storage/innobase/include/mem0mem.h index b013d597393..a1f7282b3e2 100644 --- a/storage/innobase/include/mem0mem.h +++ b/storage/innobase/include/mem0mem.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -77,7 +77,7 @@ is the maximum size for a single allocated buffer: */ /** Space needed when allocating for a user a field of length N. The space is allocated only in multiples of UNIV_MEM_ALIGNMENT. */ -#define MEM_SPACE_NEEDED(N) ut_calc_align((N), UNIV_MEM_ALIGNMENT) +#define MEM_SPACE_NEEDED(N) UT_CALC_ALIGN((N), UNIV_MEM_ALIGNMENT) #ifdef UNIV_DEBUG /** Macro for memory heap creation. @@ -348,8 +348,8 @@ struct mem_block_info_t { #define MEM_FREED_BLOCK_MAGIC_N 547711122 /* Header size for a memory heap block */ -#define MEM_BLOCK_HEADER_SIZE ut_calc_align(sizeof(mem_block_info_t),\ - UNIV_MEM_ALIGNMENT) +#define MEM_BLOCK_HEADER_SIZE UT_CALC_ALIGN(sizeof(mem_block_info_t),\ + UNIV_MEM_ALIGNMENT) #include "mem0mem.ic" #endif diff --git a/storage/innobase/include/os0proc.h b/storage/innobase/include/os0proc.h index a73ba5a9e84..69d48c4d2f6 100644 --- a/storage/innobase/include/os0proc.h +++ b/storage/innobase/include/os0proc.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -42,12 +42,6 @@ typedef unsigned long int os_process_id_t; system with os_mem_alloc_large(). */ extern ulint os_total_large_mem_allocated; -/** Whether to use large pages in the buffer pool */ -extern my_bool os_use_large_pages; - -/** Large page size. This may be a boot-time option on some platforms */ -extern uint os_large_page_size; - /** Converts the current process id to a number. @return process id as a number */ ulint diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 1614d3ead6d..33c60484085 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -128,26 +129,23 @@ Calculates fast the remainder of n/m when m is a power of two. @param n in: numerator @param m in: denominator, must be a power of two @return the remainder of n/m */ -#define ut_2pow_remainder(n, m) ((n) & ((m) - 1)) +template inline T ut_2pow_remainder(T n, T m){return n & (m - 1);} /*************************************************************//** Calculates the biggest multiple of m that is not bigger than n when m is a power of two. In other words, rounds n down to m * k. @param n in: number to round down @param m in: alignment, must be a power of two @return n rounded down to the biggest possible integer multiple of m */ -#define ut_2pow_round(n, m) ((n) & ~((m) - 1)) -/** Align a number down to a multiple of a power of two. -@param n in: number to round down -@param m in: alignment, must be a power of two -@return n rounded down to the biggest possible integer multiple of m */ -#define ut_calc_align_down(n, m) ut_2pow_round(n, m) +template inline T ut_2pow_round(T n, T m) { return n & ~(m - 1); } /********************************************************//** Calculates the smallest multiple of m that is not smaller than n when m is a power of two. In other words, rounds n up to m * k. @param n in: number to round up @param m in: alignment, must be a power of two @return n rounded up to the smallest possible integer multiple of m */ -#define ut_calc_align(n, m) (((n) + ((m) - 1)) & ~((m) - 1)) +#define UT_CALC_ALIGN(n, m) ((n + m - 1) & ~(m - 1)) +template inline T ut_calc_align(T n, T m) +{ return UT_CALC_ALIGN(n, m); } /*************************************************************//** Calculates fast the 2-logarithm of a number, rounded upward to an diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 8c17f1383df..8a80d2bbfd4 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -193,10 +193,8 @@ void log_buffer_extend(ulong len) log_sys.is_extending = true; - while (ut_calc_align_down(log_sys.buf_free, - OS_FILE_LOG_BLOCK_SIZE) - != ut_calc_align_down(log_sys.buf_next_to_write, - OS_FILE_LOG_BLOCK_SIZE)) { + while ((log_sys.buf_free ^ log_sys.buf_next_to_write) + & (OS_FILE_LOG_BLOCK_SIZE - 1)) { /* Buffer might have >1 blocks to write still. */ log_mutex_exit_all(); @@ -205,9 +203,8 @@ void log_buffer_extend(ulong len) log_mutex_enter_all(); } - ulong move_start = ut_calc_align_down( - log_sys.buf_free, - OS_FILE_LOG_BLOCK_SIZE); + ulong move_start = ut_2pow_round(log_sys.buf_free, + ulong(OS_FILE_LOG_BLOCK_SIZE)); ulong move_end = log_sys.buf_free; /* store the last log block in buffer */ @@ -900,8 +897,8 @@ log_buffer_switch() ut_ad(log_write_mutex_own()); const byte* old_buf = log_sys.buf; - ulint area_end = ut_calc_align(log_sys.buf_free, - OS_FILE_LOG_BLOCK_SIZE); + ulint area_end = ut_calc_align( + log_sys.buf_free, ulint(OS_FILE_LOG_BLOCK_SIZE)); if (log_sys.first_in_use) { log_sys.first_in_use = false; @@ -1036,8 +1033,9 @@ loop: start_offset = log_sys.buf_next_to_write; end_offset = log_sys.buf_free; - area_start = ut_calc_align_down(start_offset, OS_FILE_LOG_BLOCK_SIZE); - area_end = ut_calc_align(end_offset, OS_FILE_LOG_BLOCK_SIZE); + area_start = ut_2pow_round(start_offset, + ulint(OS_FILE_LOG_BLOCK_SIZE)); + area_end = ut_calc_align(end_offset, ulint(OS_FILE_LOG_BLOCK_SIZE)); ut_ad(area_end - area_start > 0); diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc index 0c8f8795be8..b3202992af0 100644 --- a/storage/innobase/os/os0proc.cc +++ b/storage/innobase/os/os0proc.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -25,6 +26,9 @@ Created 9/30/1995 Heikki Tuuri *******************************************************/ #include "univ.i" +#ifdef HAVE_LINUX_LARGE_PAGES +# include "mysqld.h" +#endif /* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and MAP_ANON but MAP_ANON is marked as deprecated */ @@ -38,12 +42,6 @@ MAP_ANON but MAP_ANON is marked as deprecated */ system with os_mem_alloc_large(). */ ulint os_total_large_mem_allocated = 0; -/** Whether to use large pages in the buffer pool */ -my_bool os_use_large_pages; - -/** Large page size. This may be a boot-time option on some platforms */ -uint os_large_page_size; - /** Converts the current process id to a number. @return process id as a number */ ulint @@ -66,18 +64,18 @@ os_mem_alloc_large( { void* ptr; ulint size; -#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX +#ifdef HAVE_LINUX_LARGE_PAGES int shmid; struct shmid_ds buf; - if (!os_use_large_pages || !os_large_page_size) { + if (!my_use_large_pages || !opt_large_page_size) { goto skip; } - /* Align block size to os_large_page_size */ - ut_ad(ut_is_2pow(os_large_page_size)); - size = ut_2pow_round(*n + (os_large_page_size - 1), - os_large_page_size); + /* Align block size to opt_large_page_size */ + ut_ad(ut_is_2pow(opt_large_page_size)); + size = ut_2pow_round(*n + opt_large_page_size - 1, + ulint(opt_large_page_size)); shmid = shmget(IPC_PRIVATE, (size_t) size, SHM_HUGETLB | SHM_R | SHM_W); if (shmid < 0) { @@ -109,7 +107,7 @@ os_mem_alloc_large( ib::warn() << "Using conventional memory pool"; skip: -#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */ +#endif /* HAVE_LINUX_LARGE_PAGES */ #ifdef _WIN32 SYSTEM_INFO system_info; @@ -117,10 +115,8 @@ skip: /* Align block size to system page size */ ut_ad(ut_is_2pow(system_info.dwPageSize)); - /* system_info.dwPageSize is only 32-bit. Casting to ulint is required - on 64-bit Windows. */ - size = *n = ut_2pow_round(*n + (system_info.dwPageSize - 1), - (ulint) system_info.dwPageSize); + size = *n = ut_2pow_round(*n + (system_info.dwPageSize - 1), + system_info.dwPageSize); ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); if (!ptr) { @@ -161,13 +157,13 @@ os_mem_free_large( { ut_a(os_total_large_mem_allocated >= size); -#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX - if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) { +#ifdef HAVE_LINUX_LARGE_PAGES + if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) { my_atomic_addlint( &os_total_large_mem_allocated, -size); return; } -#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */ +#endif /* HAVE_LINUX_LARGE_PAGES */ #ifdef _WIN32 /* When RELEASE memory, the size parameter must be 0. Do not use MEM_RELEASE with MEM_DECOMMIT. */ diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 6bb8c9f6d67..e4906638f6c 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -5,8 +5,8 @@ MACRO(SKIP_ROCKSDB_PLUGIN msg) RETURN() ENDMACRO() -IF (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/Makefile") - SKIP_ROCKSDB_PLUGIN("Missing Makefile in rocksdb directory. Try \"git submodule update\".") +IF (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/CMakeLists.txt") + SKIP_ROCKSDB_PLUGIN("Missing CMakeLists.txt in rocksdb directory. Try \"git submodule update\".") ENDIF() CHECK_LIBRARY_EXISTS(rt timer_delete "" HAVE_TIMER_DELETE)