Skip to content

Commit a9e8b57

Browse files
author
Sergei Golubchik
committed
percona-server-5.5.38-35.2
1 parent d60b4df commit a9e8b57

File tree

7 files changed

+57
-66
lines changed

7 files changed

+57
-66
lines changed

buf/buf0buf.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,12 @@ buf_pool_watch_is_sentinel(
16001600
buf_pool_t* buf_pool, /*!< buffer pool instance */
16011601
const buf_page_t* bpage) /*!< in: block */
16021602
{
1603+
#ifdef UNIV_SYNC_DEBUG
1604+
ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_SHARED)
1605+
|| rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX)
1606+
|| mutex_own(buf_page_get_mutex(bpage)));
1607+
#endif
1608+
16031609
ut_ad(buf_page_in_file(bpage));
16041610

16051611
if (bpage < &buf_pool->watch[0]
@@ -2048,7 +2054,9 @@ buf_page_get_zip(
20482054
mutex_enter(&buf_pool->LRU_list_mutex);
20492055
mutex_enter(block_mutex);
20502056

2051-
if (UNIV_UNLIKELY(bpage->space != space
2057+
if (UNIV_UNLIKELY((buf_page_get_state(bpage)
2058+
!= BUF_BLOCK_FILE_PAGE)
2059+
|| bpage->space != space
20522060
|| bpage->offset != offset
20532061
|| !bpage->in_LRU_list
20542062
|| !bpage->zip.data)) {

buf/buf0flu.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,11 @@ buf_flush_page_and_try_neighbors(
16061606
}
16071607

16081608
ut_a(buf_page_in_file(bpage)
1609-
|| buf_page_get_state(bpage) == BUF_BLOCK_REMOVE_HASH);
1609+
|| (buf_page_get_state(bpage) == BUF_BLOCK_REMOVE_HASH
1610+
#ifdef UNIV_DEBUG
1611+
&& !mutex_own(&buf_pool->LRU_list_mutex)
1612+
#endif
1613+
));
16101614

16111615
if (buf_flush_ready_for_flush(bpage, flush_type)) {
16121616
ulint space;

buf/buf0lru.c

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,15 @@ UNIV_INLINE
177177
ibool
178178
buf_LRU_evict_from_unzip_LRU(
179179
/*=========================*/
180-
buf_pool_t* buf_pool,
181-
ibool have_LRU_mutex)
180+
buf_pool_t* buf_pool)
182181
{
183182
ulint io_avg;
184183
ulint unzip_avg;
185184

186-
//ut_ad(buf_pool_mutex_own(buf_pool));
185+
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
187186

188-
if (!have_LRU_mutex)
189-
mutex_enter(&buf_pool->LRU_list_mutex);
190187
/* If the unzip_LRU list is empty, we can only use the LRU. */
191188
if (UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0) {
192-
if (!have_LRU_mutex)
193-
mutex_exit(&buf_pool->LRU_list_mutex);
194189
return(FALSE);
195190
}
196191

@@ -199,20 +194,14 @@ buf_LRU_evict_from_unzip_LRU(
199194
decompressed pages in the buffer pool. */
200195
if (UT_LIST_GET_LEN(buf_pool->unzip_LRU)
201196
<= UT_LIST_GET_LEN(buf_pool->LRU) / 10) {
202-
if (!have_LRU_mutex)
203-
mutex_exit(&buf_pool->LRU_list_mutex);
204197
return(FALSE);
205198
}
206199

207200
/* If eviction hasn't started yet, we assume by default
208201
that a workload is disk bound. */
209202
if (buf_pool->freed_page_clock == 0) {
210-
if (!have_LRU_mutex)
211-
mutex_exit(&buf_pool->LRU_list_mutex);
212203
return(TRUE);
213204
}
214-
if (!have_LRU_mutex)
215-
mutex_exit(&buf_pool->LRU_list_mutex);
216205

217206
/* Calculate the average over past intervals, and add the values
218207
of the current interval. */
@@ -612,6 +601,8 @@ buf_flush_or_remove_pages(
612601
ibool all_freed = TRUE;
613602
ibool must_restart = FALSE;
614603

604+
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
605+
615606
buf_flush_list_mutex_enter(buf_pool);
616607

617608
for (bpage = UT_LIST_GET_LAST(buf_pool->flush_list);
@@ -930,19 +921,18 @@ ibool
930921
buf_LRU_free_from_unzip_LRU_list(
931922
/*=============================*/
932923
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
933-
ulint n_iterations, /*!< in: how many times this has
924+
ulint n_iterations) /*!< in: how many times this has
934925
been called repeatedly without
935926
result: a high value means that
936927
we should search farther; we will
937928
search n_iterations / 5 of the
938929
unzip_LRU list, or nothing if
939930
n_iterations >= 5 */
940-
ibool have_LRU_mutex)
941931
{
942932
buf_block_t* block;
943933
ulint distance;
944934

945-
//ut_ad(buf_pool_mutex_own(buf_pool));
935+
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
946936

947937
/* Theoratically it should be much easier to find a victim
948938
from unzip_LRU as we can choose even a dirty block (as we'll
@@ -952,33 +942,26 @@ buf_LRU_free_from_unzip_LRU_list(
952942
if we have done five iterations so far. */
953943

954944
if (UNIV_UNLIKELY(n_iterations >= 5)
955-
|| !buf_LRU_evict_from_unzip_LRU(buf_pool, have_LRU_mutex)) {
945+
|| !buf_LRU_evict_from_unzip_LRU(buf_pool)) {
956946

957947
return(FALSE);
958948
}
959949

960950
distance = 100 + (n_iterations
961951
* UT_LIST_GET_LEN(buf_pool->unzip_LRU)) / 5;
962952

963-
restart:
964953
for (block = UT_LIST_GET_LAST(buf_pool->unzip_LRU);
965954
UNIV_LIKELY(block != NULL) && UNIV_LIKELY(distance > 0);
966955
block = UT_LIST_GET_PREV(unzip_LRU, block), distance--) {
967956

968957
ibool freed;
969958

970-
mutex_enter(&block->mutex);
971-
if (!block->in_unzip_LRU_list || !block->page.in_LRU_list
972-
|| buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) {
973-
mutex_exit(&block->mutex);
974-
goto restart;
975-
}
976-
977959
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
978960
ut_ad(block->in_unzip_LRU_list);
979961
ut_ad(block->page.in_LRU_list);
980962

981-
freed = buf_LRU_free_block(&block->page, FALSE, have_LRU_mutex);
963+
mutex_enter(&block->mutex);
964+
freed = buf_LRU_free_block(&block->page, FALSE, TRUE);
982965
mutex_exit(&block->mutex);
983966

984967
if (freed) {
@@ -997,46 +980,35 @@ ibool
997980
buf_LRU_free_from_common_LRU_list(
998981
/*==============================*/
999982
buf_pool_t* buf_pool,
1000-
ulint n_iterations,
983+
ulint n_iterations)
1001984
/*!< in: how many times this has been called
1002985
repeatedly without result: a high value means
1003986
that we should search farther; if
1004987
n_iterations < 10, then we search
1005988
n_iterations / 10 * buf_pool->curr_size
1006989
pages from the end of the LRU list */
1007-
ibool have_LRU_mutex)
1008990
{
1009991
buf_page_t* bpage;
1010992
ulint distance;
1011993

1012-
//ut_ad(buf_pool_mutex_own(buf_pool));
994+
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
1013995

1014996
distance = 100 + (n_iterations * buf_pool->curr_size) / 10;
1015997

1016-
restart:
1017998
for (bpage = UT_LIST_GET_LAST(buf_pool->LRU);
1018999
UNIV_LIKELY(bpage != NULL) && UNIV_LIKELY(distance > 0);
10191000
bpage = UT_LIST_GET_PREV(LRU, bpage), distance--) {
10201001

10211002
ibool freed;
10221003
unsigned accessed;
1023-
mutex_t* block_mutex = buf_page_get_mutex_enter(bpage);
1024-
1025-
if (!block_mutex) {
1026-
goto restart;
1027-
}
1028-
1029-
if (!bpage->in_LRU_list
1030-
|| !buf_page_in_file(bpage)) {
1031-
mutex_exit(block_mutex);
1032-
goto restart;
1033-
}
1004+
mutex_t* block_mutex = buf_page_get_mutex(bpage);
10341005

10351006
ut_ad(buf_page_in_file(bpage));
10361007
ut_ad(bpage->in_LRU_list);
10371008

1009+
mutex_enter(block_mutex);
10381010
accessed = buf_page_is_accessed(bpage);
1039-
freed = buf_LRU_free_block(bpage, TRUE, have_LRU_mutex);
1011+
freed = buf_LRU_free_block(bpage, TRUE, TRUE);
10401012
mutex_exit(block_mutex);
10411013

10421014
if (freed) {
@@ -1073,32 +1045,27 @@ buf_LRU_search_and_free_block(
10731045
n_iterations / 5 of the unzip_LRU list. */
10741046
{
10751047
ibool freed = FALSE;
1076-
ibool have_LRU_mutex = FALSE;
10771048

1078-
if (UT_LIST_GET_LEN(buf_pool->unzip_LRU))
1079-
have_LRU_mutex = TRUE;
1080-
1081-
//buf_pool_mutex_enter(buf_pool);
1082-
if (have_LRU_mutex)
1083-
mutex_enter(&buf_pool->LRU_list_mutex);
1049+
mutex_enter(&buf_pool->LRU_list_mutex);
10841050

1085-
freed = buf_LRU_free_from_unzip_LRU_list(buf_pool, n_iterations, have_LRU_mutex);
1051+
freed = buf_LRU_free_from_unzip_LRU_list(buf_pool, n_iterations);
10861052

10871053
if (!freed) {
10881054
freed = buf_LRU_free_from_common_LRU_list(
1089-
buf_pool, n_iterations, have_LRU_mutex);
1055+
buf_pool, n_iterations);
10901056
}
10911057

10921058
buf_pool_mutex_enter(buf_pool);
1059+
10931060
if (!freed) {
10941061
buf_pool->LRU_flush_ended = 0;
10951062
} else if (buf_pool->LRU_flush_ended > 0) {
10961063
buf_pool->LRU_flush_ended--;
10971064
}
10981065

10991066
buf_pool_mutex_exit(buf_pool);
1100-
if (have_LRU_mutex)
1101-
mutex_exit(&buf_pool->LRU_list_mutex);
1067+
1068+
mutex_exit(&buf_pool->LRU_list_mutex);
11021069

11031070
return(freed);
11041071
}

buf/buf0rea.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,13 @@ buf_read_ahead_random(
340340
return(0);
341341
}
342342

343+
buf_pool_mutex_exit(buf_pool);
344+
343345
/* Count how many blocks in the area have been recently accessed,
344346
that is, reside near the start of the LRU list. */
345347

348+
rw_lock_s_lock(&buf_pool->page_hash_latch);
349+
346350
for (i = low; i < high; i++) {
347351
const buf_page_t* bpage =
348352
buf_page_hash_get(buf_pool, space, i);
@@ -356,13 +360,13 @@ buf_read_ahead_random(
356360
if (recent_blocks
357361
>= BUF_READ_AHEAD_RANDOM_THRESHOLD(buf_pool)) {
358362

359-
buf_pool_mutex_exit(buf_pool);
363+
rw_lock_s_unlock(&buf_pool->page_hash_latch);
360364
goto read_ahead;
361365
}
362366
}
363367
}
364368

365-
buf_pool_mutex_exit(buf_pool);
369+
rw_lock_s_unlock(&buf_pool->page_hash_latch);
366370
/* Do nothing */
367371
return(0);
368372

include/buf0buf.ic

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,11 @@ buf_page_get_block(
689689
/*===============*/
690690
buf_page_t* bpage) /*!< in: control block, or NULL */
691691
{
692+
#ifdef UNIV_SYNC_DEBUG
693+
buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
694+
ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_SHARED)
695+
|| rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX));
696+
#endif
692697
if (UNIV_LIKELY(bpage != NULL)) {
693698
ut_ad(buf_page_in_file(bpage));
694699

include/univ.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ component, i.e. we show M.N.P as M.N */
6464
(INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
6565

6666
#ifndef PERCONA_INNODB_VERSION
67-
#define PERCONA_INNODB_VERSION 35.0
67+
#define PERCONA_INNODB_VERSION 35.2
6868
#endif
6969

70-
#define INNODB_VERSION_STR MYSQL_SERVER_VERSION "-" IB_TO_STR(PERCONA_INNODB_VERSION)
70+
#define INNODB_VERSION_STR MYSQL_SERVER_VERSION
7171

7272
#define REFMAN "http://dev.mysql.com/doc/refman/" \
7373
IB_TO_STR(MYSQL_MAJOR_VERSION) "." \

row/row0ins.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ row_ins_alloc_sys_fields(
143143
const dict_col_t* col;
144144
dfield_t* dfield;
145145
byte* ptr;
146+
uint len;
146147

147148
row = node->row;
148149
table = node->table;
@@ -151,35 +152,37 @@ row_ins_alloc_sys_fields(
151152
ut_ad(row && table && heap);
152153
ut_ad(dtuple_get_n_fields(row) == dict_table_get_n_cols(table));
153154

154-
/* 1. Allocate buffer for row id */
155+
/* allocate buffer to hold the needed system created hidden columns. */
156+
len = DATA_ROW_ID_LEN + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
157+
ptr = mem_heap_zalloc(heap, len);
155158

159+
/* 1. Populate row-id */
156160
col = dict_table_get_sys_col(table, DATA_ROW_ID);
157161

158162
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
159163

160-
ptr = mem_heap_zalloc(heap, DATA_ROW_ID_LEN);
161-
162164
dfield_set_data(dfield, ptr, DATA_ROW_ID_LEN);
163165

164166
node->row_id_buf = ptr;
165167

166-
/* 3. Allocate buffer for trx id */
168+
ptr += DATA_ROW_ID_LEN;
167169

170+
/* 2. Populate trx id */
168171
col = dict_table_get_sys_col(table, DATA_TRX_ID);
169172

170173
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
171-
ptr = mem_heap_zalloc(heap, DATA_TRX_ID_LEN);
172174

173175
dfield_set_data(dfield, ptr, DATA_TRX_ID_LEN);
174176

175177
node->trx_id_buf = ptr;
176178

177-
/* 4. Allocate buffer for roll ptr */
179+
ptr += DATA_TRX_ID_LEN;
180+
181+
/* 3. Populate roll ptr */
178182

179183
col = dict_table_get_sys_col(table, DATA_ROLL_PTR);
180184

181185
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
182-
ptr = mem_heap_zalloc(heap, DATA_ROLL_PTR_LEN);
183186

184187
dfield_set_data(dfield, ptr, DATA_ROLL_PTR_LEN);
185188
}

0 commit comments

Comments
 (0)