Skip to content

Commit 415fe3f

Browse files
author
Sergei Golubchik
committed
percona-server-5.6.19-67.0
1 parent 6cb3146 commit 415fe3f

35 files changed

+925
-269
lines changed

btr/btr0cur.cc

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,6 @@ btr_rec_free_externally_stored_fields(
202202
mtr_t* mtr); /*!< in: mini-transaction handle which contains
203203
an X-latch to record page and to the index
204204
tree */
205-
/***********************************************************//**
206-
Gets the externally stored size of a record, in units of a database page.
207-
@return externally stored part, in units of a database page */
208-
static
209-
ulint
210-
btr_rec_get_externally_stored_len(
211-
/*==============================*/
212-
const rec_t* rec, /*!< in: record */
213-
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
214205
#endif /* !UNIV_HOTBACKUP */
215206

216207
/******************************************************//**
@@ -4238,15 +4229,15 @@ btr_rec_get_field_ref_offs(
42384229
#define btr_rec_get_field_ref(rec, offsets, n) \
42394230
((rec) + btr_rec_get_field_ref_offs(offsets, n))
42404231

4241-
/***********************************************************//**
4242-
Gets the externally stored size of a record, in units of a database page.
4232+
/** Gets the externally stored size of a record, in units of a database page.
4233+
@param[in] rec record
4234+
@param[in] offsets array returned by rec_get_offsets()
42434235
@return externally stored part, in units of a database page */
4244-
static
4236+
42454237
ulint
42464238
btr_rec_get_externally_stored_len(
4247-
/*==============================*/
4248-
const rec_t* rec, /*!< in: record */
4249-
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
4239+
const rec_t* rec,
4240+
const ulint* offsets)
42504241
{
42514242
ulint n_fields;
42524243
ulint total_extern_len = 0;

btr/btr0sea.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,10 @@ btr_search_validate_one_table(
19441944
buf_pool_t* buf_pool;
19451945
index_id_t page_index_id;
19461946

1947-
buf_pool = buf_pool_from_bpage((buf_page_t*) block);
1947+
buf_pool = buf_pool_from_bpage((buf_page_t *) block);
1948+
/* Prevent BUF_BLOCK_FILE_PAGE -> BUF_BLOCK_REMOVE_HASH
1949+
transition until we lock the block mutex */
1950+
mutex_enter(&buf_pool->LRU_list_mutex);
19481951

19491952
if (UNIV_LIKELY(buf_block_get_state(block)
19501953
== BUF_BLOCK_FILE_PAGE)) {
@@ -1980,6 +1983,7 @@ btr_search_validate_one_table(
19801983
}
19811984

19821985
mutex_enter(&block->mutex);
1986+
mutex_exit(&buf_pool->LRU_list_mutex);
19831987

19841988
ut_a(!dict_index_is_ibuf(block->index));
19851989

buf/buf0flu.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,12 @@ buf_flush_ready_for_flush(
546546
ut_ad(flush_type < BUF_FLUSH_N_TYPES);
547547
ut_ad(mutex_own(buf_page_get_mutex(bpage))
548548
|| flush_type == BUF_FLUSH_LIST);
549-
ut_a(buf_page_in_file(bpage));
549+
ut_a(buf_page_in_file(bpage)
550+
|| (buf_page_get_state(bpage) == BUF_BLOCK_REMOVE_HASH
551+
#ifdef UNIV_DEBUG
552+
&& !mutex_own(&buf_pool_from_bpage(bpage)->LRU_list_mutex)
553+
#endif
554+
));
550555

551556
if (bpage->oldest_modification == 0
552557
|| buf_page_get_io_fix_unlocked(bpage) != BUF_IO_NONE) {
@@ -557,6 +562,7 @@ buf_flush_ready_for_flush(
557562

558563
switch (flush_type) {
559564
case BUF_FLUSH_LIST:
565+
return(buf_page_get_state(bpage) != BUF_BLOCK_REMOVE_HASH);
560566
case BUF_FLUSH_LRU:
561567
case BUF_FLUSH_SINGLE_PAGE:
562568
return(true);
@@ -1363,7 +1369,11 @@ buf_flush_page_and_try_neighbors(
13631369
}
13641370

13651371
ut_a(buf_page_in_file(bpage)
1366-
|| buf_page_get_state(bpage) == BUF_BLOCK_REMOVE_HASH);
1372+
|| (buf_page_get_state(bpage) == BUF_BLOCK_REMOVE_HASH
1373+
#ifdef UNIV_DEBUG
1374+
&& !mutex_own(&buf_pool->LRU_list_mutex)
1375+
#endif
1376+
));
13671377

13681378
if (buf_flush_ready_for_flush(bpage, flush_type)) {
13691379
buf_pool_t* buf_pool;
@@ -1649,7 +1659,7 @@ buf_do_LRU_batch(
16491659
{
16501660
if (buf_LRU_evict_from_unzip_LRU(buf_pool)) {
16511661
n->unzip_LRU_evicted
1652-
+= buf_free_from_unzip_LRU_list_batch(buf_pool, max);
1662+
= buf_free_from_unzip_LRU_list_batch(buf_pool, max);
16531663
} else {
16541664
n->unzip_LRU_evicted = 0;
16551665
}
@@ -1948,6 +1958,7 @@ buf_flush_LRU(
19481958
if (!buf_flush_start(buf_pool, BUF_FLUSH_LRU)) {
19491959
n->flushed = 0;
19501960
n->evicted = 0;
1961+
n->unzip_LRU_evicted = 0;
19511962
return(false);
19521963
}
19531964

@@ -2365,6 +2376,10 @@ af_get_pct_for_dirty()
23652376
{
23662377
ulint dirty_pct = buf_get_modified_ratio_pct();
23672378

2379+
if (dirty_pct > 0 && srv_max_buf_pool_modified_pct == 0) {
2380+
return(100);
2381+
}
2382+
23682383
ut_a(srv_max_dirty_pages_pct_lwm
23692384
<= srv_max_buf_pool_modified_pct);
23702385

buf/buf0lru.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ buf_flush_or_remove_pages(
595595
buf_page_t* bpage;
596596
ulint processed = 0;
597597

598+
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
599+
598600
buf_flush_list_mutex_enter(buf_pool);
599601

600602
rescan:

dict/dict0dict.cc

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2012, Facebook Inc.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -50,6 +50,7 @@ UNIV_INTERN dict_index_t* dict_ind_compact;
5050
#include "btr0btr.h"
5151
#include "btr0cur.h"
5252
#include "btr0sea.h"
53+
#include "os0once.h"
5354
#include "page0zip.h"
5455
#include "page0page.h"
5556
#include "pars0pars.h"
@@ -102,7 +103,7 @@ UNIV_INTERN ulong zip_pad_max = 50;
102103
UNIV_INTERN mysql_pfs_key_t dict_operation_lock_key;
103104
UNIV_INTERN mysql_pfs_key_t index_tree_rw_lock_key;
104105
UNIV_INTERN mysql_pfs_key_t index_online_log_key;
105-
UNIV_INTERN mysql_pfs_key_t dict_table_stats_latch_key;
106+
UNIV_INTERN mysql_pfs_key_t dict_table_stats_key;
106107
#endif /* UNIV_PFS_RWLOCK */
107108

108109
#ifdef UNIV_PFS_MUTEX
@@ -319,6 +320,82 @@ dict_mutex_exit_for_mysql(void)
319320
mutex_exit(&(dict_sys->mutex));
320321
}
321322

323+
/** Allocate and init a dict_table_t's stats latch.
324+
This function must not be called concurrently on the same table object.
325+
@param[in,out] table_void table whose stats latch to create */
326+
static
327+
void
328+
dict_table_stats_latch_alloc(
329+
void* table_void)
330+
{
331+
dict_table_t* table = static_cast<dict_table_t*>(table_void);
332+
333+
table->stats_latch = new(std::nothrow) rw_lock_t;
334+
335+
ut_a(table->stats_latch != NULL);
336+
337+
rw_lock_create(dict_table_stats_key, table->stats_latch,
338+
SYNC_INDEX_TREE);
339+
}
340+
341+
/** Deinit and free a dict_table_t's stats latch.
342+
This function must not be called concurrently on the same table object.
343+
@param[in,out] table table whose stats latch to free */
344+
static
345+
void
346+
dict_table_stats_latch_free(
347+
dict_table_t* table)
348+
{
349+
rw_lock_free(table->stats_latch);
350+
delete table->stats_latch;
351+
}
352+
353+
/** Create a dict_table_t's stats latch or delay for lazy creation.
354+
This function is only called from either single threaded environment
355+
or from a thread that has not shared the table object with other threads.
356+
@param[in,out] table table whose stats latch to create
357+
@param[in] enabled if false then the latch is disabled
358+
and dict_table_stats_lock()/unlock() become noop on this table. */
359+
360+
void
361+
dict_table_stats_latch_create(
362+
dict_table_t* table,
363+
bool enabled)
364+
{
365+
if (!enabled) {
366+
table->stats_latch = NULL;
367+
table->stats_latch_created = os_once::DONE;
368+
return;
369+
}
370+
371+
#ifdef HAVE_ATOMIC_BUILTINS
372+
/* We create this lazily the first time it is used. */
373+
table->stats_latch = NULL;
374+
table->stats_latch_created = os_once::NEVER_DONE;
375+
#else /* HAVE_ATOMIC_BUILTINS */
376+
377+
dict_table_stats_latch_alloc(table);
378+
379+
table->stats_latch_created = os_once::DONE;
380+
#endif /* HAVE_ATOMIC_BUILTINS */
381+
}
382+
383+
/** Destroy a dict_table_t's stats latch.
384+
This function is only called from either single threaded environment
385+
or from a thread that has not shared the table object with other threads.
386+
@param[in,out] table table whose stats latch to destroy */
387+
388+
void
389+
dict_table_stats_latch_destroy(
390+
dict_table_t* table)
391+
{
392+
if (table->stats_latch_created == os_once::DONE
393+
&& table->stats_latch != NULL) {
394+
395+
dict_table_stats_latch_free(table);
396+
}
397+
}
398+
322399
/**********************************************************************//**
323400
Lock the appropriate latch to protect a given table's statistics. */
324401
UNIV_INTERN
@@ -331,6 +408,14 @@ dict_table_stats_lock(
331408
ut_ad(table != NULL);
332409
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
333410

411+
#ifdef HAVE_ATOMIC_BUILTINS
412+
os_once::do_or_wait_for_done(
413+
&table->stats_latch_created,
414+
dict_table_stats_latch_alloc, table);
415+
#else /* HAVE_ATOMIC_BUILTINS */
416+
ut_ad(table->stats_latch_created == os_once::DONE);
417+
#endif /* HAVE_ATOMIC_BUILTINS */
418+
334419
if (table->stats_latch == NULL) {
335420
/* This is a dummy table object that is private in the current
336421
thread and is not shared between multiple threads, thus we
@@ -5156,8 +5241,6 @@ dict_table_print(
51565241
index = UT_LIST_GET_NEXT(indexes, index);
51575242
}
51585243

5159-
table->stat_initialized = FALSE;
5160-
51615244
dict_table_stats_unlock(table, RW_X_LATCH);
51625245

51635246
foreign = UT_LIST_GET_FIRST(table->foreign_list);

dict/dict0mem.cc

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2012, Facebook Inc.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -98,13 +98,9 @@ dict_mem_table_create(
9898

9999
ut_d(table->magic_n = DICT_TABLE_MAGIC_N);
100100

101-
if (!nonshared) {
102-
table->stats_latch = new rw_lock_t;
103-
rw_lock_create(dict_table_stats_latch_key, table->stats_latch,
104-
SYNC_INDEX_TREE);
105-
} else {
106-
table->stats_latch = NULL;
107-
}
101+
/* true means that the stats latch will be enabled -
102+
dict_table_stats_lock() will not be noop. */
103+
dict_table_stats_latch_create(table, true);
108104

109105
#ifndef UNIV_HOTBACKUP
110106

@@ -168,17 +164,13 @@ dict_mem_table_free(
168164
}
169165
}
170166
#ifndef UNIV_HOTBACKUP
171-
if (table->stats_latch) {
167+
if (table->autoinc_lock) {
172168

173169
mutex_free(&(table->autoinc_mutex));
174170
}
175171
#endif /* UNIV_HOTBACKUP */
176172

177-
if (table->stats_latch) {
178-
179-
rw_lock_free(table->stats_latch);
180-
delete table->stats_latch;
181-
}
173+
dict_table_stats_latch_destroy(table);
182174

183175
ut_free(table->name);
184176
mem_heap_free(table->heap);

0 commit comments

Comments
 (0)