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

Proposed by George Ormond Lorch III
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 462
Proposed branch: lp:~gl-az/percona-server/5.1-686534-881001
Merge into: lp:percona-server/5.1
Diff against target: 190 lines (+78/-37)
2 files modified
Percona-Server/storage/innodb_plugin/buf/buf0lru.c (+77/-36)
Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc (+1/-1)
To merge this branch: bzr merge lp:~gl-az/percona-server/5.1-686534-881001
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Alexey Kopytov Pending
Review via email: mp+119062@code.launchpad.net

Description of the change

http://jenkins.percona.com/view/PS%205.1/job/percona-server-5.1-param/360/

Fixed issue where LRU dump would hold LRU_list_mutex during the entire
dump process. Now the mutex is only held when navigating the buffer
pool and filling LRU dump pages but not during the LRU dump disk write.

Fixed issue where the last LRU dump page is not written to the LRU dump
file if the page is exactly filled.

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

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Is "prefill fill" on the line 64 a typo?

review: Approve
Revision history for this message
George Ormond Lorch III (gl-az) wrote :

> Is "prefill fill" on the line 64 a typo?
Yes, fixed only that and re-pushed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/storage/innodb_plugin/buf/buf0lru.c'
2--- Percona-Server/storage/innodb_plugin/buf/buf0lru.c 2012-05-17 17:30:18 +0000
3+++ Percona-Server/storage/innodb_plugin/buf/buf0lru.c 2012-08-10 19:00:29 +0000
4@@ -2100,6 +2100,11 @@
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+ UNIV_PAGE_SIZE)
13
14 UNIV_INTERN
15 ibool
16@@ -2111,17 +2116,19 @@
17 byte* buffer_base = NULL;
18 byte* buffer = NULL;
19 buf_page_t* bpage;
20+ buf_page_t* first_bpage;
21 ulint buffers;
22 ulint offset;
23- ibool ret = FALSE;
24+ ulint pages_written;
25 ulint i;
26+ ulint total_pages;
27
28 for (i = 0; i < srv_n_data_files; i++) {
29 if (strstr(srv_data_file_names[i], LRU_DUMP_FILE) != NULL) {
30 fprintf(stderr,
31 " InnoDB: The name '%s' seems to be used for"
32- " innodb_data_file_path. Dumping LRU list is not"
33- " done for safeness.\n", LRU_DUMP_FILE);
34+ " innodb_data_file_path. Dumping LRU list is"
35+ " not done for safeness.\n", LRU_DUMP_FILE);
36 goto end;
37 }
38 }
39@@ -2144,12 +2151,27 @@
40 }
41
42 mutex_enter(&LRU_list_mutex);
43- bpage = UT_LIST_GET_LAST(buf_pool->LRU);
44-
45- buffers = offset = 0;
46- while (bpage != NULL) {
47+ bpage = first_bpage = UT_LIST_GET_FIRST(buf_pool->LRU);
48+ total_pages = UT_LIST_GET_LEN(buf_pool->LRU);
49+
50+ buffers = offset = pages_written = 0;
51+ while (bpage != NULL && (pages_written++ < total_pages)) {
52+
53+ buf_page_t* next_bpage = UT_LIST_GET_NEXT(LRU, bpage);
54+
55+ if (next_bpage == first_bpage) {
56+ mutex_exit(&LRU_list_mutex);
57+ success = FALSE;
58+ fprintf(stderr,
59+ "InnoDB: detected cycle in LRU, skipping "
60+ "dump\n");
61+ goto end;
62+ }
63+
64+ /* prefill with 0xFF so any unused page entries will
65+ stop the reloading process */
66 if (offset == 0) {
67- memset(buffer, 0, UNIV_PAGE_SIZE);
68+ memset(buffer, 0xFF, UNIV_PAGE_SIZE);
69 }
70
71 mach_write_to_4(buffer + offset * 4, bpage->space);
72@@ -2158,50 +2180,69 @@
73 offset++;
74
75 if (offset == UNIV_PAGE_SIZE/4) {
76+ mutex_t *next_block_mutex = NULL;
77+
78 if (srv_shutdown_state != SRV_SHUTDOWN_NONE) {
79- success = 0;
80+ mutex_exit(&LRU_list_mutex);
81+ success = FALSE;
82 fprintf(stderr,
83 " InnoDB: stopped dumping lru pages"
84 " because of server shutdown.\n");
85 goto end;
86 }
87- success = os_file_write(LRU_DUMP_FILE, dump_file, buffer,
88- (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
89- (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
90- UNIV_PAGE_SIZE);
91+
92+ /* while writing file, release buffer pool mutex but
93+ keep the next page fixed so we don't worry about
94+ our list iterator becoming invalid */
95+ if (next_bpage) {
96+ next_block_mutex = buf_page_get_mutex(
97+ next_bpage);
98+
99+ mutex_enter(next_block_mutex);
100+ next_bpage->buf_fix_count++;
101+ mutex_exit(next_block_mutex);
102+ }
103+ mutex_exit(&LRU_list_mutex);
104+
105+ success = LRU_OS_FILE_WRITE();
106+
107+ /* grab this again here so that next_bpage
108+ can't be purged when we drop the fix_count */
109+ mutex_enter(&LRU_list_mutex);
110+
111+ if (next_bpage) {
112+ mutex_enter(next_block_mutex);
113+ next_bpage->buf_fix_count--;
114+ mutex_exit(next_block_mutex);
115+ }
116 if (!success) {
117- mutex_exit(&LRU_list_mutex);
118+ mutex_enter(&LRU_list_mutex);
119 fprintf(stderr,
120- " InnoDB: cannot write page %lu of %s\n",
121+ " InnoDB: cannot write page"
122+ " %lu of %s\n",
123 buffers, LRU_DUMP_FILE);
124 goto end;
125 }
126 buffers++;
127 offset = 0;
128+ bpage = next_bpage;
129+ } else {
130+ bpage = UT_LIST_GET_NEXT(LRU, bpage);
131 }
132-
133- bpage = UT_LIST_GET_PREV(LRU, bpage);
134- }
135+ } /* while(bpage ...) */
136 mutex_exit(&LRU_list_mutex);
137
138+ /* if offset > 0 means that there are some unwritten leftovers */
139 if (offset == 0) {
140- memset(buffer, 0, UNIV_PAGE_SIZE);
141- }
142-
143- mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
144- offset++;
145- mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
146- offset++;
147-
148- success = os_file_write(LRU_DUMP_FILE, dump_file, buffer,
149- (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
150- (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
151- UNIV_PAGE_SIZE);
152- if (!success) {
153- goto end;
154- }
155-
156- ret = TRUE;
157+ memset(buffer, 0xFF, UNIV_PAGE_SIZE);
158+ }
159+
160+ mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
161+ offset++;
162+ mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
163+ offset++;
164+
165+ success = LRU_OS_FILE_WRITE();
166 end:
167 if (dump_file != -1) {
168 if (success) {
169@@ -2216,7 +2257,7 @@
170 if (buffer_base)
171 ut_free(buffer_base);
172
173- return(ret);
174+ return(success);
175 }
176
177 typedef struct {
178
179=== modified file 'Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc'
180--- Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc 2012-07-02 02:04:45 +0000
181+++ Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc 2012-08-10 19:00:29 +0000
182@@ -12070,7 +12070,7 @@
183 NULL, NULL, 0, 0, UINT_MAX32, 0);
184
185 static MYSQL_SYSVAR_BOOL(blocking_lru_restore, innobase_blocking_lru_restore,
186- PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
187+ PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
188 "Block XtraDB startup process until buffer pool is full restored from a "
189 "dump file (if present). Disabled by default.",
190 NULL, NULL, FALSE);

Subscribers

People subscribed via source and target branches