Skip to content

Commit 04af573

Browse files
committed
Merge branch 'merge-innodb-5.6' into 10.0
2 parents cfeedbf + 86ff4da commit 04af573

File tree

18 files changed

+394
-105
lines changed

18 files changed

+394
-105
lines changed

storage/innobase/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -29,6 +29,9 @@ IF(UNIX)
2929
ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1)
3030
LINK_LIBRARIES(aio)
3131
ENDIF()
32+
IF(HAVE_LIBNUMA)
33+
LINK_LIBRARIES(numa)
34+
ENDIF()
3235
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*")
3336
ADD_DEFINITIONS("-DUNIV_HPUX")
3437
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
@@ -151,6 +154,18 @@ IF(NOT CMAKE_CROSSCOMPILING)
151154
}"
152155
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
153156
)
157+
CHECK_C_SOURCE_RUNS(
158+
"#include<stdint.h>
159+
int main()
160+
{
161+
unsigned char c;
162+
163+
__atomic_test_and_set(&c, __ATOMIC_ACQUIRE);
164+
__atomic_clear(&c, __ATOMIC_RELEASE);
165+
return(0);
166+
}"
167+
HAVE_IB_GCC_ATOMIC_TEST_AND_SET
168+
)
154169
ENDIF()
155170

156171
IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
@@ -173,6 +188,10 @@ IF(HAVE_IB_GCC_ATOMIC_THREAD_FENCE)
173188
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1)
174189
ENDIF()
175190

191+
IF(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
192+
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_TEST_AND_SET=1)
193+
ENDIF()
194+
176195
# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
177196
IF(NOT CMAKE_CROSSCOMPILING)
178197
CHECK_C_SOURCE_RUNS(

storage/innobase/btr/btr0cur.cc

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2008, Google Inc.
55
Copyright (c) 2012, Facebook Inc.
66
@@ -2118,6 +2118,7 @@ btr_cur_optimistic_update(
21182118
ulint max_size;
21192119
ulint new_rec_size;
21202120
ulint old_rec_size;
2121+
ulint max_ins_size = 0;
21212122
dtuple_t* new_entry;
21222123
roll_ptr_t roll_ptr;
21232124
ulint i;
@@ -2246,6 +2247,10 @@ btr_cur_optimistic_update(
22462247
: (old_rec_size
22472248
+ page_get_max_insert_size_after_reorganize(page, 1));
22482249

2250+
if (!page_zip) {
2251+
max_ins_size = page_get_max_insert_size_after_reorganize(page, 1);
2252+
}
2253+
22492254
if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
22502255
&& (max_size >= new_rec_size))
22512256
|| (page_get_n_recs(page) <= 1))) {
@@ -2305,12 +2310,15 @@ btr_cur_optimistic_update(
23052310
ut_ad(err == DB_SUCCESS);
23062311

23072312
func_exit:
2308-
if (page_zip
2309-
&& !(flags & BTR_KEEP_IBUF_BITMAP)
2313+
if (!(flags & BTR_KEEP_IBUF_BITMAP)
23102314
&& !dict_index_is_clust(index)
23112315
&& page_is_leaf(page)) {
2312-
/* Update the free bits in the insert buffer. */
2313-
ibuf_update_free_bits_zip(block, mtr);
2316+
2317+
if (page_zip) {
2318+
ibuf_update_free_bits_zip(block, mtr);
2319+
} else {
2320+
ibuf_update_free_bits_low(block, max_ins_size, mtr);
2321+
}
23142322
}
23152323

23162324
return(err);
@@ -2445,6 +2453,7 @@ btr_cur_pessimistic_update(
24452453
ibool was_first;
24462454
ulint n_reserved = 0;
24472455
ulint n_ext;
2456+
ulint max_ins_size = 0;
24482457

24492458
*offsets = NULL;
24502459
*big_rec = NULL;
@@ -2623,6 +2632,10 @@ btr_cur_pessimistic_update(
26232632
}
26242633
}
26252634

2635+
if (!page_zip) {
2636+
max_ins_size = page_get_max_insert_size_after_reorganize(page, 1);
2637+
}
2638+
26262639
/* Store state of explicit locks on rec on the page infimum record,
26272640
before deleting rec. The page infimum acts as a dummy carrier of the
26282641
locks, taking care also of lock releases, before we can move the locks
@@ -2668,13 +2681,18 @@ btr_cur_pessimistic_update(
26682681
rec_offs_make_valid(
26692682
page_cursor->rec, index, *offsets);
26702683
}
2671-
} else if (page_zip &&
2672-
!dict_index_is_clust(index)
2684+
} else if (!dict_index_is_clust(index)
26732685
&& page_is_leaf(page)) {
2686+
26742687
/* Update the free bits in the insert buffer.
26752688
This is the same block which was skipped by
26762689
BTR_KEEP_IBUF_BITMAP. */
2677-
ibuf_update_free_bits_zip(block, mtr);
2690+
if (page_zip) {
2691+
ibuf_update_free_bits_zip(block, mtr);
2692+
} else {
2693+
ibuf_update_free_bits_low(block, max_ins_size,
2694+
mtr);
2695+
}
26782696
}
26792697

26802698
err = DB_SUCCESS;

storage/innobase/buf/buf0buf.cc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Created 11/5/1995 Heikki Tuuri
5353
#include "page0zip.h"
5454
#include "srv0mon.h"
5555
#include "buf0checksum.h"
56+
#ifdef HAVE_LIBNUMA
57+
#include <numa.h>
58+
#include <numaif.h>
59+
#endif // HAVE_LIBNUMA
5660

5761
/*
5862
IMPLEMENTATION OF THE BUFFER POOL
@@ -1112,6 +1116,22 @@ buf_chunk_init(
11121116
return(NULL);
11131117
}
11141118

1119+
#ifdef HAVE_LIBNUMA
1120+
if (srv_numa_interleave) {
1121+
int st = mbind(chunk->mem, chunk->mem_size,
1122+
MPOL_INTERLEAVE,
1123+
numa_all_nodes_ptr->maskp,
1124+
numa_all_nodes_ptr->size,
1125+
MPOL_MF_MOVE);
1126+
if (st != 0) {
1127+
ib_logf(IB_LOG_LEVEL_WARN,
1128+
"Failed to set NUMA memory policy of buffer"
1129+
" pool page frames to MPOL_INTERLEAVE"
1130+
" (error: %s).", strerror(errno));
1131+
}
1132+
}
1133+
#endif // HAVE_LIBNUMA
1134+
11151135
/* Allocate the block descriptors from
11161136
the start of the memory block. */
11171137
chunk->blocks = (buf_block_t*) chunk->mem;
@@ -1442,6 +1462,21 @@ buf_pool_init(
14421462
ut_ad(n_instances <= MAX_BUFFER_POOLS);
14431463
ut_ad(n_instances == srv_buf_pool_instances);
14441464

1465+
#ifdef HAVE_LIBNUMA
1466+
if (srv_numa_interleave) {
1467+
ib_logf(IB_LOG_LEVEL_INFO,
1468+
"Setting NUMA memory policy to MPOL_INTERLEAVE");
1469+
if (set_mempolicy(MPOL_INTERLEAVE,
1470+
numa_all_nodes_ptr->maskp,
1471+
numa_all_nodes_ptr->size) != 0) {
1472+
ib_logf(IB_LOG_LEVEL_WARN,
1473+
"Failed to set NUMA memory policy to"
1474+
" MPOL_INTERLEAVE (error: %s).",
1475+
strerror(errno));
1476+
}
1477+
}
1478+
#endif // HAVE_LIBNUMA
1479+
14451480
buf_pool_ptr = (buf_pool_t*) mem_zalloc(
14461481
n_instances * sizeof *buf_pool_ptr);
14471482

@@ -1462,6 +1497,18 @@ buf_pool_init(
14621497

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

1500+
#ifdef HAVE_LIBNUMA
1501+
if (srv_numa_interleave) {
1502+
ib_logf(IB_LOG_LEVEL_INFO,
1503+
"Setting NUMA memory policy to MPOL_DEFAULT");
1504+
if (set_mempolicy(MPOL_DEFAULT, NULL, 0) != 0) {
1505+
ib_logf(IB_LOG_LEVEL_WARN,
1506+
"Failed to set NUMA memory policy to"
1507+
" MPOL_DEFAULT (error: %s).", strerror(errno));
1508+
}
1509+
}
1510+
#endif // HAVE_LIBNUMA
1511+
14651512
return(DB_SUCCESS);
14661513
}
14671514

storage/innobase/dict/dict0dict.cc

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,6 @@ dict_index_remove_from_cache_low(
212212
dict_index_t* index, /*!< in, own: index */
213213
ibool lru_evict); /*!< in: TRUE if page being evicted
214214
to make room in the table LRU list */
215-
/**********************************************************************//**
216-
Removes a table object from the dictionary cache. */
217-
static
218-
void
219-
dict_table_remove_from_cache_low(
220-
/*=============================*/
221-
dict_table_t* table, /*!< in, own: table */
222-
ibool lru_evict); /*!< in: TRUE if evicting from LRU */
223215
#ifdef UNIV_DEBUG
224216
/**********************************************************************//**
225217
Validate the dictionary table LRU list.
@@ -787,6 +779,45 @@ dict_table_get_all_fts_indexes(
787779
return(ib_vector_size(indexes));
788780
}
789781

782+
/** Store autoinc value when the table is evicted.
783+
@param[in] table table evicted */
784+
UNIV_INTERN
785+
void
786+
dict_table_autoinc_store(
787+
const dict_table_t* table)
788+
{
789+
ut_ad(mutex_own(&dict_sys->mutex));
790+
791+
if (table->autoinc != 0) {
792+
ut_ad(dict_sys->autoinc_map->find(table->id)
793+
== dict_sys->autoinc_map->end());
794+
795+
dict_sys->autoinc_map->insert(
796+
std::pair<table_id_t, ib_uint64_t>(
797+
table->id, table->autoinc));
798+
}
799+
}
800+
801+
/** Restore autoinc value when the table is loaded.
802+
@param[in] table table loaded */
803+
UNIV_INTERN
804+
void
805+
dict_table_autoinc_restore(
806+
dict_table_t* table)
807+
{
808+
ut_ad(mutex_own(&dict_sys->mutex));
809+
810+
autoinc_map_t::iterator it;
811+
it = dict_sys->autoinc_map->find(table->id);
812+
813+
if (it != dict_sys->autoinc_map->end()) {
814+
table->autoinc = it->second;
815+
ut_ad(table->autoinc != 0);
816+
817+
dict_sys->autoinc_map->erase(it);
818+
}
819+
}
820+
790821
/********************************************************************//**
791822
Reads the next autoinc value (== autoinc counter value), 0 if not yet
792823
initialized.
@@ -1080,6 +1111,8 @@ dict_init(void)
10801111
mutex_create(dict_foreign_err_mutex_key,
10811112
&dict_foreign_err_mutex, SYNC_NO_ORDER_CHECK);
10821113
}
1114+
1115+
dict_sys->autoinc_map = new autoinc_map_t();
10831116
}
10841117

10851118
/**********************************************************************//**
@@ -1327,6 +1360,8 @@ dict_table_add_to_cache(
13271360
UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_non_LRU, table);
13281361
}
13291362

1363+
dict_table_autoinc_restore(table);
1364+
13301365
ut_ad(dict_lru_validate());
13311366

13321367
dict_sys->size += mem_heap_get_size(table->heap)
@@ -2016,7 +2051,6 @@ dict_table_change_id_in_cache(
20162051

20172052
/**********************************************************************//**
20182053
Removes a table object from the dictionary cache. */
2019-
static
20202054
void
20212055
dict_table_remove_from_cache_low(
20222056
/*=============================*/
@@ -2078,6 +2112,10 @@ dict_table_remove_from_cache_low(
20782112

20792113
ut_ad(dict_lru_validate());
20802114

2115+
if (lru_evict) {
2116+
dict_table_autoinc_store(table);
2117+
}
2118+
20812119
if (lru_evict && table->drop_aborted) {
20822120
/* Do as dict_table_try_drop_aborted() does. */
20832121

@@ -6820,6 +6858,8 @@ dict_close(void)
68206858
mutex_free(&dict_foreign_err_mutex);
68216859
}
68226860

6861+
delete dict_sys->autoinc_map;
6862+
68236863
mem_free(dict_sys);
68246864
dict_sys = NULL;
68256865
}

0 commit comments

Comments
 (0)