Skip to content

Commit

Permalink
Merge branch 'merge-innodb-5.6' into 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Oct 9, 2015
2 parents cfeedbf + 86ff4da commit 04af573
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 105 deletions.
21 changes: 20 additions & 1 deletion storage/innobase/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 @@ -29,6 +29,9 @@ IF(UNIX)
ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1)
LINK_LIBRARIES(aio)
ENDIF()
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 @@ -151,6 +154,18 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
)
CHECK_C_SOURCE_RUNS(
"#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
)
ENDIF()

IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
Expand All @@ -173,6 +188,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
IF(NOT CMAKE_CROSSCOMPILING)
CHECK_C_SOURCE_RUNS(
Expand Down
34 changes: 26 additions & 8 deletions storage/innobase/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 @@ -2118,6 +2118,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 @@ -2246,6 +2247,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 @@ -2305,12 +2310,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 @@ -2445,6 +2453,7 @@ btr_cur_pessimistic_update(
ibool was_first;
ulint n_reserved = 0;
ulint n_ext;
ulint max_ins_size = 0;

*offsets = NULL;
*big_rec = NULL;
Expand Down Expand Up @@ -2623,6 +2632,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 @@ -2668,13 +2681,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
47 changes: 47 additions & 0 deletions storage/innobase/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

/*
IMPLEMENTATION OF THE BUFFER POOL
Expand Down Expand Up @@ -1112,6 +1116,22 @@ buf_chunk_init(
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 @@ -1442,6 +1462,21 @@ 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);

Expand All @@ -1462,6 +1497,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/innobase/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 @@ -6820,6 +6858,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 04af573

Please sign in to comment.