Skip to content

Commit

Permalink
Merge branch 'merge/merge-xtradb-5.6' into 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Dec 13, 2015
2 parents 5b3c100 + 1e270d5 commit 359ae59
Show file tree
Hide file tree
Showing 32 changed files with 618 additions and 240 deletions.
21 changes: 20 additions & 1 deletion storage/xtradb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
#
# 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
Expand Down Expand Up @@ -49,6 +49,9 @@ IF(UNIX)
LINK_LIBRARIES(${AIO_LIBRARY})
ENDIF()
ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1")
IF(HAVE_LIBNUMA)
LINK_LIBRARIES(numa)
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*")
ADD_DEFINITIONS("-DUNIV_HPUX")
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
Expand Down Expand Up @@ -170,6 +173,18 @@ IF(NOT MSVC)
}"
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
)
CHECK_C_SOURCE(
"#include<stdint.h>
int main()
{
unsigned char c;
__atomic_test_and_set(&c, __ATOMIC_ACQUIRE);
__atomic_clear(&c, __ATOMIC_RELEASE);
return(0);
}"
HAVE_IB_GCC_ATOMIC_TEST_AND_SET
)

IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
Expand All @@ -192,6 +207,10 @@ IF(HAVE_IB_GCC_ATOMIC_THREAD_FENCE)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1)
ENDIF()

IF(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_TEST_AND_SET=1)
ENDIF()

# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
CHECK_C_SOURCE(
"
Expand Down
46 changes: 33 additions & 13 deletions storage/xtradb/btr/btr0cur.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2012, Facebook Inc.
Expand Down Expand Up @@ -284,8 +284,13 @@ btr_cur_latch_leaves(
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
== page_is_comp(page));
ut_a(btr_page_get_next(get_block->frame, mtr)
== page_get_page_no(page));

/* For fake_change mode we avoid a detailed validation
as it operate in tweaked format where-in validation
may fail. */
ut_a(sibling_mode == RW_NO_LATCH
|| btr_page_get_next(get_block->frame, mtr)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
if (sibling_mode == RW_NO_LATCH) {
/* btr_block_get() called with RW_NO_LATCH will
Expand Down Expand Up @@ -1383,9 +1388,6 @@ btr_cur_optimistic_insert(
}
#endif /* UNIV_DEBUG */

ut_ad((thr && thr_get_trx(thr)->fake_changes)
|| mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));

leaf = page_is_leaf(page);

/* Calculate the record size when entry is converted to a record */
Expand Down Expand Up @@ -2265,6 +2267,7 @@ btr_cur_optimistic_update(
ulint max_size;
ulint new_rec_size;
ulint old_rec_size;
ulint max_ins_size = 0;
dtuple_t* new_entry;
roll_ptr_t roll_ptr;
ulint i;
Expand Down Expand Up @@ -2394,6 +2397,10 @@ btr_cur_optimistic_update(
: (old_rec_size
+ page_get_max_insert_size_after_reorganize(page, 1));

if (!page_zip) {
max_ins_size = page_get_max_insert_size_after_reorganize(page, 1);
}

if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
&& (max_size >= new_rec_size))
|| (page_get_n_recs(page) <= 1))) {
Expand Down Expand Up @@ -2459,12 +2466,15 @@ btr_cur_optimistic_update(
ut_ad(err == DB_SUCCESS);

func_exit:
if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP)
if (!(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index)
&& page_is_leaf(page)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);

if (page_zip) {
ibuf_update_free_bits_zip(block, mtr);
} else {
ibuf_update_free_bits_low(block, max_ins_size, mtr);
}
}

return(err);
Expand Down Expand Up @@ -2600,6 +2610,7 @@ btr_cur_pessimistic_update(
ulint n_reserved = 0;
ulint n_ext;
trx_t* trx;
ulint max_ins_size = 0;

*offsets = NULL;
*big_rec = NULL;
Expand Down Expand Up @@ -2800,6 +2811,10 @@ btr_cur_pessimistic_update(
}
}

if (!page_zip) {
max_ins_size = page_get_max_insert_size_after_reorganize(page, 1);
}

/* Store state of explicit locks on rec on the page infimum record,
before deleting rec. The page infimum acts as a dummy carrier of the
locks, taking care also of lock releases, before we can move the locks
Expand Down Expand Up @@ -2845,13 +2860,18 @@ btr_cur_pessimistic_update(
rec_offs_make_valid(
page_cursor->rec, index, *offsets);
}
} else if (page_zip &&
!dict_index_is_clust(index)
} else if (!dict_index_is_clust(index)
&& page_is_leaf(page)) {

/* Update the free bits in the insert buffer.
This is the same block which was skipped by
BTR_KEEP_IBUF_BITMAP. */
ibuf_update_free_bits_zip(block, mtr);
if (page_zip) {
ibuf_update_free_bits_zip(block, mtr);
} else {
ibuf_update_free_bits_low(block, max_ins_size,
mtr);
}
}

err = DB_SUCCESS;
Expand Down
58 changes: 51 additions & 7 deletions storage/xtradb/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Created 11/5/1995 Heikki Tuuri
#include "page0zip.h"
#include "srv0mon.h"
#include "buf0checksum.h"
#ifdef HAVE_LIBNUMA
#include <numa.h>
#include <numaif.h>
#endif // HAVE_LIBNUMA
#include "trx0trx.h"
#include "srv0start.h"

Expand Down Expand Up @@ -1167,8 +1171,7 @@ buf_chunk_init(
/*===========*/
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
buf_chunk_t* chunk, /*!< out: chunk of buffers */
ulint mem_size, /*!< in: requested size in bytes */
ibool populate) /*!< in: virtual page preallocation */
ulint mem_size) /*!< in: requested size in bytes */
{
buf_block_t* block;
byte* frame;
Expand All @@ -1184,13 +1187,29 @@ buf_chunk_init(
+ (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE);

chunk->mem_size = mem_size;
chunk->mem = os_mem_alloc_large(&chunk->mem_size, populate);
chunk->mem = os_mem_alloc_large(&chunk->mem_size);

if (UNIV_UNLIKELY(chunk->mem == NULL)) {

return(NULL);
}

#ifdef HAVE_LIBNUMA
if (srv_numa_interleave) {
int st = mbind(chunk->mem, chunk->mem_size,
MPOL_INTERLEAVE,
numa_all_nodes_ptr->maskp,
numa_all_nodes_ptr->size,
MPOL_MF_MOVE);
if (st != 0) {
ib_logf(IB_LOG_LEVEL_WARN,
"Failed to set NUMA memory policy of buffer"
" pool page frames to MPOL_INTERLEAVE"
" (error: %s).", strerror(errno));
}
}
#endif // HAVE_LIBNUMA

/* Allocate the block descriptors from
the start of the memory block. */
chunk->blocks = (buf_block_t*) chunk->mem;
Expand Down Expand Up @@ -1387,7 +1406,6 @@ buf_pool_init_instance(
/*===================*/
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
ulint buf_pool_size, /*!< in: size in bytes */
ibool populate, /*!< in: virtual page preallocation */
ulint instance_no) /*!< in: id of the instance */
{
ulint i;
Expand Down Expand Up @@ -1416,7 +1434,7 @@ buf_pool_init_instance(

UT_LIST_INIT(buf_pool->free);

if (!buf_chunk_init(buf_pool, chunk, buf_pool_size, populate)) {
if (!buf_chunk_init(buf_pool, chunk, buf_pool_size)) {
mem_free(chunk);
mem_free(buf_pool);

Expand Down Expand Up @@ -1522,7 +1540,6 @@ dberr_t
buf_pool_init(
/*==========*/
ulint total_size, /*!< in: size of the total pool in bytes */
ibool populate, /*!< in: virtual page preallocation */
ulint n_instances) /*!< in: number of instances */
{
ulint i;
Expand All @@ -1532,13 +1549,28 @@ buf_pool_init(
ut_ad(n_instances <= MAX_BUFFER_POOLS);
ut_ad(n_instances == srv_buf_pool_instances);

#ifdef HAVE_LIBNUMA
if (srv_numa_interleave) {
ib_logf(IB_LOG_LEVEL_INFO,
"Setting NUMA memory policy to MPOL_INTERLEAVE");
if (set_mempolicy(MPOL_INTERLEAVE,
numa_all_nodes_ptr->maskp,
numa_all_nodes_ptr->size) != 0) {
ib_logf(IB_LOG_LEVEL_WARN,
"Failed to set NUMA memory policy to"
" MPOL_INTERLEAVE (error: %s).",
strerror(errno));
}
}
#endif // HAVE_LIBNUMA

buf_pool_ptr = (buf_pool_t*) mem_zalloc(
n_instances * sizeof *buf_pool_ptr);

for (i = 0; i < n_instances; i++) {
buf_pool_t* ptr = &buf_pool_ptr[i];

if (buf_pool_init_instance(ptr, size, populate, i) != DB_SUCCESS) {
if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) {

/* Free all the instances created so far. */
buf_pool_free(i);
Expand All @@ -1552,6 +1584,18 @@ buf_pool_init(

btr_search_sys_create(buf_pool_get_curr_size() / sizeof(void*) / 64);

#ifdef HAVE_LIBNUMA
if (srv_numa_interleave) {
ib_logf(IB_LOG_LEVEL_INFO,
"Setting NUMA memory policy to MPOL_DEFAULT");
if (set_mempolicy(MPOL_DEFAULT, NULL, 0) != 0) {
ib_logf(IB_LOG_LEVEL_WARN,
"Failed to set NUMA memory policy to"
" MPOL_DEFAULT (error: %s).", strerror(errno));
}
}
#endif // HAVE_LIBNUMA

return(DB_SUCCESS);
}

Expand Down
58 changes: 49 additions & 9 deletions storage/xtradb/dict/dict0dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,6 @@ dict_index_remove_from_cache_low(
dict_index_t* index, /*!< in, own: index */
ibool lru_evict); /*!< in: TRUE if page being evicted
to make room in the table LRU list */
/**********************************************************************//**
Removes a table object from the dictionary cache. */
static
void
dict_table_remove_from_cache_low(
/*=============================*/
dict_table_t* table, /*!< in, own: table */
ibool lru_evict); /*!< in: TRUE if evicting from LRU */
#ifdef UNIV_DEBUG
/**********************************************************************//**
Validate the dictionary table LRU list.
Expand Down Expand Up @@ -787,6 +779,45 @@ dict_table_get_all_fts_indexes(
return(ib_vector_size(indexes));
}

/** Store autoinc value when the table is evicted.
@param[in] table table evicted */
UNIV_INTERN
void
dict_table_autoinc_store(
const dict_table_t* table)
{
ut_ad(mutex_own(&dict_sys->mutex));

if (table->autoinc != 0) {
ut_ad(dict_sys->autoinc_map->find(table->id)
== dict_sys->autoinc_map->end());

dict_sys->autoinc_map->insert(
std::pair<table_id_t, ib_uint64_t>(
table->id, table->autoinc));
}
}

/** Restore autoinc value when the table is loaded.
@param[in] table table loaded */
UNIV_INTERN
void
dict_table_autoinc_restore(
dict_table_t* table)
{
ut_ad(mutex_own(&dict_sys->mutex));

autoinc_map_t::iterator it;
it = dict_sys->autoinc_map->find(table->id);

if (it != dict_sys->autoinc_map->end()) {
table->autoinc = it->second;
ut_ad(table->autoinc != 0);

dict_sys->autoinc_map->erase(it);
}
}

/********************************************************************//**
Reads the next autoinc value (== autoinc counter value), 0 if not yet
initialized.
Expand Down Expand Up @@ -1080,6 +1111,8 @@ dict_init(void)
mutex_create(dict_foreign_err_mutex_key,
&dict_foreign_err_mutex, SYNC_NO_ORDER_CHECK);
}

dict_sys->autoinc_map = new autoinc_map_t();
}

/**********************************************************************//**
Expand Down Expand Up @@ -1327,6 +1360,8 @@ dict_table_add_to_cache(
UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_non_LRU, table);
}

dict_table_autoinc_restore(table);

ut_ad(dict_lru_validate());

dict_sys->size += mem_heap_get_size(table->heap)
Expand Down Expand Up @@ -2016,7 +2051,6 @@ dict_table_change_id_in_cache(

/**********************************************************************//**
Removes a table object from the dictionary cache. */
static
void
dict_table_remove_from_cache_low(
/*=============================*/
Expand Down Expand Up @@ -2078,6 +2112,10 @@ dict_table_remove_from_cache_low(

ut_ad(dict_lru_validate());

if (lru_evict) {
dict_table_autoinc_store(table);
}

if (lru_evict && table->drop_aborted) {
/* Do as dict_table_try_drop_aborted() does. */

Expand Down Expand Up @@ -6848,6 +6886,8 @@ dict_close(void)
mutex_free(&dict_foreign_err_mutex);
}

delete dict_sys->autoinc_map;

mem_free(dict_sys);
dict_sys = NULL;
}
Expand Down
Loading

0 comments on commit 359ae59

Please sign in to comment.