Merge lp:~gl-az/percona-server/5.5-686534-881001 into lp:percona-server/5.5

Proposed by George Ormond Lorch III
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 308
Proposed branch: lp:~gl-az/percona-server/5.5-686534-881001
Merge into: lp:percona-server/5.5
Diff against target: 213 lines (+87/-43)
2 files modified
Percona-Server/storage/innobase/buf/buf0lru.c (+86/-42)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+1/-1)
To merge this branch: bzr merge lp:~gl-az/percona-server/5.5-686534-881001
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+125782@code.launchpad.net

Commit message

Fixed issue where LRU dump would hold LRU_list_mutex during the entire dump process for each buffer pool. Now the mutex is only held when navigating the buffer pool and filling LRU dump pages but not during the LRU dump disk write. Modified dump page logic to allow number of dump pages that are to be filled on each buffer pool mutex cycle to be specified at compile time.

Fixed issue where innodb_blocking_buffer_pool_restore does not take an optional bool argument similar to other bool options.

Description of the change

Fixed issue where LRU dump would hold LRU_list_mutex during the entire dump process for each buffer pool. Now the mutex is only held when navigating the buffer pool and filling LRU dump pages but not during the LRU dump disk write. Modified dump page logic to allow number of dump pages that are to be filled on each buffer pool mutex cycle to be specified at compile time.

Fixed issue where innodb_blocking_buffer_pool_restore does not take an optional bool argument similar to other bool options.

http://jenkins.percona.com/view/PS%205.5/job/percona-server-5.5-param/515/

To post a comment you must log in.
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/storage/innobase/buf/buf0lru.c'
2--- Percona-Server/storage/innobase/buf/buf0lru.c 2012-09-17 13:08:32 +0000
3+++ Percona-Server/storage/innobase/buf/buf0lru.c 2012-09-21 18:10:26 +0000
4@@ -2531,6 +2531,14 @@
5 Dump the LRU page list to the specific file. */
6 #define LRU_DUMP_FILE "ib_lru_dump"
7 #define LRU_DUMP_TEMP_FILE "ib_lru_dump.tmp"
8+#define LRU_OS_FILE_WRITE() \
9+ os_file_write(LRU_DUMP_FILE, dump_file, buffer, \
10+ (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL, \
11+ (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)), \
12+ buffer_size)
13+#define LRU_DUMP_PAGE_COUNT 1 /* Specifies how many dump pages
14+ should be filled for each hold
15+ of the LRU_list_mutex. */
16
17 UNIV_INTERN
18 ibool
19@@ -2541,23 +2549,30 @@
20 ibool success;
21 byte* buffer_base = NULL;
22 byte* buffer = NULL;
23+ const ulint buffer_size = LRU_DUMP_PAGE_COUNT * UNIV_PAGE_SIZE;
24 buf_page_t* bpage;
25+ buf_page_t* first_bpage;
26 ulint buffers;
27 ulint offset;
28- ibool ret = FALSE;
29+ ulint pages_written;
30 ulint i;
31+ ulint total_pages;
32+
33+ /* Sanity test to make sure page size is a multiple of
34+ assumed dump record size */
35+ ut_a(UNIV_PAGE_SIZE % 8 == 0);
36
37 for (i = 0; i < srv_n_data_files; i++) {
38 if (strstr(srv_data_file_names[i], LRU_DUMP_FILE) != NULL) {
39 fprintf(stderr,
40 " InnoDB: The name '%s' seems to be used for"
41- " innodb_data_file_path. For safety, dumping of the LRU list"
42- " is not being done.\n", LRU_DUMP_FILE);
43+ " innodb_data_file_path. Dumping LRU list is"
44+ " not done for safeness.\n", LRU_DUMP_FILE);
45 goto end;
46 }
47 }
48
49- buffer_base = ut_malloc(2 * UNIV_PAGE_SIZE);
50+ buffer_base = ut_malloc(UNIV_PAGE_SIZE + buffer_size);
51 buffer = ut_align(buffer_base, UNIV_PAGE_SIZE);
52 if (!buffer) {
53 fprintf(stderr,
54@@ -2577,18 +2592,28 @@
55 }
56
57 buffers = offset = 0;
58-
59 for (i = 0; i < srv_buf_pool_instances; i++) {
60 buf_pool_t* buf_pool;
61
62 buf_pool = buf_pool_from_array(i);
63
64 mutex_enter(&buf_pool->LRU_list_mutex);
65- bpage = UT_LIST_GET_LAST(buf_pool->LRU);
66-
67- while (bpage != NULL) {
68- if (offset == 0) {
69- memset(buffer, 0, UNIV_PAGE_SIZE);
70+ bpage = first_bpage = UT_LIST_GET_FIRST(buf_pool->LRU);
71+ total_pages = UT_LIST_GET_LEN(buf_pool->LRU);
72+
73+ pages_written = 0;
74+ while (bpage != NULL && (pages_written++ < total_pages)) {
75+
76+ buf_page_t* next_bpage = UT_LIST_GET_NEXT(LRU, bpage);
77+
78+ if (next_bpage == first_bpage) {
79+ /* Do not release list mutex here, it will be
80+ released just outside this while loop */
81+ fprintf(stderr,
82+ "InnoDB: detected cycle in LRU for"
83+ " buffer pool %lu, skipping to next"
84+ " buffer pool.\n", i);
85+ break;
86 }
87
88 mach_write_to_4(buffer + offset * 4, bpage->space);
89@@ -2596,52 +2621,71 @@
90 mach_write_to_4(buffer + offset * 4, bpage->offset);
91 offset++;
92
93- if (offset == UNIV_PAGE_SIZE/4) {
94+ ut_a(offset <= buffer_size);
95+ if (offset == buffer_size/4) {
96+ mutex_t *next_block_mutex = NULL;
97+
98 if (srv_shutdown_state != SRV_SHUTDOWN_NONE) {
99- success = 0;
100+ mutex_exit(&buf_pool->LRU_list_mutex);
101+ success = FALSE;
102 fprintf(stderr,
103 " InnoDB: stopped dumping lru"
104 " pages because of server"
105 " shutdown.\n");
106- }
107- success = os_file_write(LRU_DUMP_FILE, dump_file, buffer,
108- (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
109- (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
110- UNIV_PAGE_SIZE);
111+ goto end;
112+ }
113+
114+ /* While writing file, release buffer pool
115+ mutex but keep the next page fixed so we
116+ don't worry about our list iterator becoming
117+ invalid */
118+ if (next_bpage) {
119+ next_block_mutex = buf_page_get_mutex(
120+ next_bpage);
121+
122+ mutex_enter(next_block_mutex);
123+ next_bpage->buf_fix_count++;
124+ mutex_exit(next_block_mutex);
125+ }
126+ mutex_exit(&buf_pool->LRU_list_mutex);
127+
128+ success = LRU_OS_FILE_WRITE();
129+
130+ /* Grab this here so that next_bpage can't
131+ be purged when we drop the fix_count */
132+ mutex_enter(&buf_pool->LRU_list_mutex);
133+
134+ if (next_bpage) {
135+ mutex_enter(next_block_mutex);
136+ next_bpage->buf_fix_count--;
137+ mutex_exit(next_block_mutex);
138+ }
139+
140 if (!success) {
141 mutex_exit(&buf_pool->LRU_list_mutex);
142 fprintf(stderr,
143- " InnoDB: cannot write page %lu of %s\n",
144+ " InnoDB: cannot write page"
145+ " %lu of %s\n",
146 buffers, LRU_DUMP_FILE);
147 goto end;
148 }
149 buffers++;
150 offset = 0;
151+
152+ bpage = next_bpage;
153+ } else {
154+ bpage = UT_LIST_GET_NEXT(LRU, bpage);
155 }
156-
157- bpage = UT_LIST_GET_PREV(LRU, bpage);
158- }
159+ } /* while(bpage ...) */
160 mutex_exit(&buf_pool->LRU_list_mutex);
161- }
162-
163- if (offset == 0) {
164- memset(buffer, 0, UNIV_PAGE_SIZE);
165- }
166-
167- mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
168- offset++;
169- mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
170- offset++;
171-
172- success = os_file_write(LRU_DUMP_FILE, dump_file, buffer,
173- (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
174- (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
175- UNIV_PAGE_SIZE);
176- if (!success) {
177- goto end;
178- }
179-
180- ret = TRUE;
181+ } /* for(srv_buf_pool_instances ...) */
182+
183+ mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
184+ offset++;
185+ mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
186+ offset++;
187+
188+ success = LRU_OS_FILE_WRITE();
189 end:
190 if (dump_file != -1) {
191 if (success) {
192@@ -2656,7 +2700,7 @@
193 if (buffer_base)
194 ut_free(buffer_base);
195
196- return(ret);
197+ return(success);
198 }
199
200 typedef struct {
201
202=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
203--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-09-17 13:08:32 +0000
204+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-09-21 18:10:26 +0000
205@@ -12837,7 +12837,7 @@
206
207 static MYSQL_SYSVAR_BOOL(blocking_buffer_pool_restore,
208 innobase_blocking_lru_restore,
209- PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
210+ PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
211 "Block XtraDB startup process until buffer pool is full restored from a "
212 "dump file (if present). Disabled by default.",
213 NULL, NULL, FALSE);

Subscribers

People subscribed via source and target branches