Skip to content

Commit 86ff4da

Browse files
committed
5.6.27
1 parent 5654412 commit 86ff4da

File tree

18 files changed

+393
-118
lines changed

18 files changed

+393
-118
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")
@@ -145,6 +148,18 @@ IF(NOT CMAKE_CROSSCOMPILING)
145148
}"
146149
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
147150
)
151+
CHECK_C_SOURCE_RUNS(
152+
"#include<stdint.h>
153+
int main()
154+
{
155+
unsigned char c;
156+
157+
__atomic_test_and_set(&c, __ATOMIC_ACQUIRE);
158+
__atomic_clear(&c, __ATOMIC_RELEASE);
159+
return(0);
160+
}"
161+
HAVE_IB_GCC_ATOMIC_TEST_AND_SET
162+
)
148163
ENDIF()
149164

150165
IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
@@ -167,6 +182,10 @@ IF(HAVE_IB_GCC_ATOMIC_THREAD_FENCE)
167182
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1)
168183
ENDIF()
169184

185+
IF(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
186+
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_TEST_AND_SET=1)
187+
ENDIF()
188+
170189
# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
171190
IF(NOT CMAKE_CROSSCOMPILING)
172191
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
@@ -2117,6 +2117,7 @@ btr_cur_optimistic_update(
21172117
ulint max_size;
21182118
ulint new_rec_size;
21192119
ulint old_rec_size;
2120+
ulint max_ins_size = 0;
21202121
dtuple_t* new_entry;
21212122
roll_ptr_t roll_ptr;
21222123
ulint i;
@@ -2245,6 +2246,10 @@ btr_cur_optimistic_update(
22452246
: (old_rec_size
22462247
+ page_get_max_insert_size_after_reorganize(page, 1));
22472248

2249+
if (!page_zip) {
2250+
max_ins_size = page_get_max_insert_size_after_reorganize(page, 1);
2251+
}
2252+
22482253
if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
22492254
&& (max_size >= new_rec_size))
22502255
|| (page_get_n_recs(page) <= 1))) {
@@ -2304,12 +2309,15 @@ btr_cur_optimistic_update(
23042309
ut_ad(err == DB_SUCCESS);
23052310

23062311
func_exit:
2307-
if (page_zip
2308-
&& !(flags & BTR_KEEP_IBUF_BITMAP)
2312+
if (!(flags & BTR_KEEP_IBUF_BITMAP)
23092313
&& !dict_index_is_clust(index)
23102314
&& page_is_leaf(page)) {
2311-
/* Update the free bits in the insert buffer. */
2312-
ibuf_update_free_bits_zip(block, mtr);
2315+
2316+
if (page_zip) {
2317+
ibuf_update_free_bits_zip(block, mtr);
2318+
} else {
2319+
ibuf_update_free_bits_low(block, max_ins_size, mtr);
2320+
}
23132321
}
23142322

23152323
return(err);
@@ -2444,6 +2452,7 @@ btr_cur_pessimistic_update(
24442452
ibool was_first;
24452453
ulint n_reserved = 0;
24462454
ulint n_ext;
2455+
ulint max_ins_size = 0;
24472456

24482457
*offsets = NULL;
24492458
*big_rec = NULL;
@@ -2622,6 +2631,10 @@ btr_cur_pessimistic_update(
26222631
}
26232632
}
26242633

2634+
if (!page_zip) {
2635+
max_ins_size = page_get_max_insert_size_after_reorganize(page, 1);
2636+
}
2637+
26252638
/* Store state of explicit locks on rec on the page infimum record,
26262639
before deleting rec. The page infimum acts as a dummy carrier of the
26272640
locks, taking care also of lock releases, before we can move the locks
@@ -2667,13 +2680,18 @@ btr_cur_pessimistic_update(
26672680
rec_offs_make_valid(
26682681
page_cursor->rec, index, *offsets);
26692682
}
2670-
} else if (page_zip &&
2671-
!dict_index_is_clust(index)
2683+
} else if (!dict_index_is_clust(index)
26722684
&& page_is_leaf(page)) {
2685+
26732686
/* Update the free bits in the insert buffer.
26742687
This is the same block which was skipped by
26752688
BTR_KEEP_IBUF_BITMAP. */
2676-
ibuf_update_free_bits_zip(block, mtr);
2689+
if (page_zip) {
2690+
ibuf_update_free_bits_zip(block, mtr);
2691+
} else {
2692+
ibuf_update_free_bits_low(block, max_ins_size,
2693+
mtr);
2694+
}
26772695
}
26782696

26792697
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
@@ -207,14 +207,6 @@ dict_index_remove_from_cache_low(
207207
dict_index_t* index, /*!< in, own: index */
208208
ibool lru_evict); /*!< in: TRUE if page being evicted
209209
to make room in the table LRU list */
210-
/**********************************************************************//**
211-
Removes a table object from the dictionary cache. */
212-
static
213-
void
214-
dict_table_remove_from_cache_low(
215-
/*=============================*/
216-
dict_table_t* table, /*!< in, own: table */
217-
ibool lru_evict); /*!< in: TRUE if evicting from LRU */
218210
#ifdef UNIV_DEBUG
219211
/**********************************************************************//**
220212
Validate the dictionary table LRU list.
@@ -748,6 +740,45 @@ dict_table_get_all_fts_indexes(
748740
return(ib_vector_size(indexes));
749741
}
750742

743+
/** Store autoinc value when the table is evicted.
744+
@param[in] table table evicted */
745+
UNIV_INTERN
746+
void
747+
dict_table_autoinc_store(
748+
const dict_table_t* table)
749+
{
750+
ut_ad(mutex_own(&dict_sys->mutex));
751+
752+
if (table->autoinc != 0) {
753+
ut_ad(dict_sys->autoinc_map->find(table->id)
754+
== dict_sys->autoinc_map->end());
755+
756+
dict_sys->autoinc_map->insert(
757+
std::pair<table_id_t, ib_uint64_t>(
758+
table->id, table->autoinc));
759+
}
760+
}
761+
762+
/** Restore autoinc value when the table is loaded.
763+
@param[in] table table loaded */
764+
UNIV_INTERN
765+
void
766+
dict_table_autoinc_restore(
767+
dict_table_t* table)
768+
{
769+
ut_ad(mutex_own(&dict_sys->mutex));
770+
771+
autoinc_map_t::iterator it;
772+
it = dict_sys->autoinc_map->find(table->id);
773+
774+
if (it != dict_sys->autoinc_map->end()) {
775+
table->autoinc = it->second;
776+
ut_ad(table->autoinc != 0);
777+
778+
dict_sys->autoinc_map->erase(it);
779+
}
780+
}
781+
751782
/********************************************************************//**
752783
Reads the next autoinc value (== autoinc counter value), 0 if not yet
753784
initialized.
@@ -1041,6 +1072,8 @@ dict_init(void)
10411072
mutex_create(dict_foreign_err_mutex_key,
10421073
&dict_foreign_err_mutex, SYNC_NO_ORDER_CHECK);
10431074
}
1075+
1076+
dict_sys->autoinc_map = new autoinc_map_t();
10441077
}
10451078

10461079
/**********************************************************************//**
@@ -1288,6 +1321,8 @@ dict_table_add_to_cache(
12881321
UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_non_LRU, table);
12891322
}
12901323

1324+
dict_table_autoinc_restore(table);
1325+
12911326
ut_ad(dict_lru_validate());
12921327

12931328
dict_sys->size += mem_heap_get_size(table->heap)
@@ -1978,7 +2013,6 @@ dict_table_change_id_in_cache(
19782013

19792014
/**********************************************************************//**
19802015
Removes a table object from the dictionary cache. */
1981-
static
19822016
void
19832017
dict_table_remove_from_cache_low(
19842018
/*=============================*/
@@ -2040,6 +2074,10 @@ dict_table_remove_from_cache_low(
20402074

20412075
ut_ad(dict_lru_validate());
20422076

2077+
if (lru_evict) {
2078+
dict_table_autoinc_store(table);
2079+
}
2080+
20432081
if (lru_evict && table->drop_aborted) {
20442082
/* Do as dict_table_try_drop_aborted() does. */
20452083

@@ -6330,6 +6368,8 @@ dict_close(void)
63306368
mutex_free(&dict_foreign_err_mutex);
63316369
}
63326370

6371+
delete dict_sys->autoinc_map;
6372+
63336373
mem_free(dict_sys);
63346374
dict_sys = NULL;
63356375
}

0 commit comments

Comments
 (0)