Merge lp:~laurynas-biveinis/percona-server/bug1086680-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis
Status: Rejected
Rejected by: Alexey Kopytov
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1086680-5.5
Merge into: lp:percona-server/5.5
Diff against target: 297 lines (+75/-11)
6 files modified
Percona-Server/storage/innobase/buf/buf0buf.c (+30/-3)
Percona-Server/storage/innobase/buf/buf0flu.c (+36/-8)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+2/-0)
Percona-Server/storage/innobase/include/buf0buf.h (+4/-0)
Percona-Server/storage/innobase/include/sync0sync.h (+2/-0)
Percona-Server/storage/innobase/sync/sync0sync.c (+1/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1086680-5.5
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Needs Resubmitting
Laurynas Biveinis Pending
Review via email: mp+144471@code.launchpad.net

This proposal supersedes a proposal from 2013-01-18.

Description of the change

Merge bug 1086680 fix from 5.1
http://jenkins.percona.com/job/percona-server-5.5-param/641/
Additionally tested locally by a UNIV_SYNC_DEBUG build, MTR --suite=innodb.
No BT or ST, but blocks BT 16274 QA.

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

Same comment as for 5.1.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Same comments as for 5.1.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) :
review: Needs Resubmitting

Unmerged revisions

410. By Laurynas Biveinis

Merge bug 1086680 fix from 5.1.

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/buf0buf.c'
2--- Percona-Server/storage/innobase/buf/buf0buf.c 2013-01-18 03:34:53 +0000
3+++ Percona-Server/storage/innobase/buf/buf0buf.c 2013-01-23 10:49:28 +0000
4@@ -310,6 +310,7 @@
5 #ifdef UNIV_PFS_MUTEX
6 UNIV_INTERN mysql_pfs_key_t buffer_block_mutex_key;
7 UNIV_INTERN mysql_pfs_key_t buf_pool_mutex_key;
8+UNIV_INTERN mysql_pfs_key_t buf_pool_zip_dirty_flush_mutex_key;
9 UNIV_INTERN mysql_pfs_key_t buf_pool_zip_mutex_key;
10 UNIV_INTERN mysql_pfs_key_t buf_pool_LRU_list_mutex_key;
11 UNIV_INTERN mysql_pfs_key_t buf_pool_free_list_mutex_key;
12@@ -1262,6 +1263,9 @@
13 &buf_pool->page_hash_latch, SYNC_BUF_PAGE_HASH);
14 mutex_create(buf_pool_free_list_mutex_key,
15 &buf_pool->free_list_mutex, SYNC_BUF_FREE_LIST);
16+ mutex_create(buf_pool_zip_dirty_flush_mutex_key,
17+ &buf_pool->zip_dirty_flush_mutex,
18+ SYNC_BUF_ZIP_DIRTY_FLUSH);
19 mutex_create(buf_pool_zip_free_mutex_key,
20 &buf_pool->zip_free_mutex, SYNC_BUF_ZIP_FREE);
21 mutex_create(buf_pool_zip_hash_mutex_key,
22@@ -2641,6 +2645,7 @@
23 switch (buf_block_get_state(block)) {
24 buf_page_t* bpage;
25 ibool success;
26+ ibool is_zip_dirty;
27
28 case BUF_BLOCK_FILE_PAGE:
29 if (block_mutex == &buf_pool->zip_mutex) {
30@@ -2653,6 +2658,8 @@
31 case BUF_BLOCK_ZIP_PAGE:
32 case BUF_BLOCK_ZIP_DIRTY:
33 ut_ad(block_mutex == &buf_pool->zip_mutex);
34+ is_zip_dirty
35+ = (buf_block_get_state(block) == BUF_BLOCK_ZIP_DIRTY);
36 bpage = &block->page;
37 /* Protect bpage->buf_fix_count. */
38 //mutex_enter(&buf_pool->zip_mutex);
39@@ -2683,6 +2690,13 @@
40 block_mutex = &block->mutex;
41
42 //buf_pool_mutex_enter(buf_pool);
43+ if (is_zip_dirty) {
44+ /* We have a dirty compressed block for this page, but
45+ no uncompressed block. As we will replace the block on
46+ the flush list, block any flushes from acquiring this
47+ block. */
48+ mutex_enter(&buf_pool->zip_dirty_flush_mutex);
49+ }
50 mutex_enter(&buf_pool->LRU_list_mutex);
51 rw_lock_x_lock(&buf_pool->page_hash_latch);
52 mutex_enter(block_mutex);
53@@ -2708,6 +2722,10 @@
54 }
55 rw_lock_x_unlock(&buf_pool->page_hash_latch);
56 mutex_exit(&buf_pool->LRU_list_mutex);
57+ if (is_zip_dirty) {
58+ mutex_exit(&buf_pool->
59+ zip_dirty_flush_mutex);
60+ }
61 goto loop2;
62 }
63 }
64@@ -2716,11 +2734,14 @@
65
66 if (UNIV_UNLIKELY
67 (bpage->buf_fix_count
68- || buf_page_get_io_fix(bpage) != BUF_IO_NONE)) {
69+ || buf_page_get_io_fix(bpage) != BUF_IO_NONE
70+ || is_zip_dirty != (buf_page_get_state(bpage)
71+ == BUF_BLOCK_ZIP_DIRTY))) {
72
73 mutex_exit(&buf_pool->zip_mutex);
74- /* The block was buffer-fixed or I/O-fixed
75- while buf_pool->mutex was not held by this thread.
76+ /* The block was buffer-fixed or I/O-fixed or changed
77+ from zip clean to zip dirty or back while the mutexes
78+ were not held by this thread.
79 Free the block that was allocated and try again.
80 This should be extremely unlikely. */
81
82@@ -2729,6 +2750,9 @@
83
84 rw_lock_x_unlock(&buf_pool->page_hash_latch);
85 mutex_exit(&buf_pool->LRU_list_mutex);
86+ if (is_zip_dirty) {
87+ mutex_exit(&buf_pool->zip_dirty_flush_mutex);
88+ }
89 goto wait_until_unfixed;
90 }
91
92@@ -2767,6 +2791,9 @@
93 buf_unzip_LRU_add_block(block, FALSE);
94
95 mutex_exit(&buf_pool->LRU_list_mutex);
96+ if (is_zip_dirty) {
97+ mutex_exit(&buf_pool->zip_dirty_flush_mutex);
98+ }
99
100 block->page.buf_fix_count = 1;
101 buf_block_set_io_fix(block, BUF_IO_READ);
102
103=== modified file 'Percona-Server/storage/innobase/buf/buf0flu.c'
104--- Percona-Server/storage/innobase/buf/buf0flu.c 2012-06-05 10:36:15 +0000
105+++ Percona-Server/storage/innobase/buf/buf0flu.c 2013-01-23 10:49:28 +0000
106@@ -470,12 +470,14 @@
107 enum buf_flush flush_type)/*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
108 {
109 #ifdef UNIV_DEBUG
110- //buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
111+ buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
112 //ut_ad(buf_pool_mutex_own(buf_pool));
113 #endif
114 //ut_a(buf_page_in_file(bpage));
115 ut_ad(mutex_own(buf_page_get_mutex(bpage)));
116- ut_ad(flush_type == BUF_FLUSH_LRU || BUF_FLUSH_LIST);
117+ ut_ad(flush_type == BUF_FLUSH_LRU
118+ || (flush_type == BUF_FLUSH_LIST
119+ && mutex_own(&buf_pool->zip_dirty_flush_mutex)));
120
121 if (buf_page_in_file(bpage) && bpage->oldest_modification != 0
122 && buf_page_get_io_fix(bpage) == BUF_IO_NONE) {
123@@ -586,6 +588,8 @@
124 //ut_ad(buf_pool_mutex_own(buf_pool));
125 /* Must reside in the same buffer pool. */
126 ut_ad(buf_pool == buf_pool_from_bpage(dpage));
127+ ut_ad((buf_page_get_state(bpage) != BUF_BLOCK_ZIP_DIRTY)
128+ || mutex_own(&buf_pool->zip_dirty_flush_mutex));
129
130 ut_ad(mutex_own(buf_page_get_mutex(bpage)));
131
132@@ -1277,7 +1281,9 @@
133 mutex_t* block_mutex;
134 ibool is_uncompressed;
135
136- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
137+ ut_ad(flush_type == BUF_FLUSH_LRU
138+ || (flush_type == BUF_FLUSH_LIST
139+ && mutex_own(&buf_pool->zip_dirty_flush_mutex)));
140 //ut_ad(buf_pool_mutex_own(buf_pool));
141 #ifdef UNIV_SYNC_DEBUG
142 ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_SHARED));
143@@ -1294,6 +1300,12 @@
144
145 buf_page_set_io_fix(bpage, BUF_IO_WRITE);
146
147+ /* I/O fix prevents the block relocation, thus OK to release
148+ temporarily */
149+ if (flush_type == BUF_FLUSH_LIST) {
150+ mutex_exit(&buf_pool->zip_dirty_flush_mutex);
151+ }
152+
153 buf_page_set_flush_type(bpage, flush_type);
154
155 if (buf_pool->n_flush[flush_type] == 0) {
156@@ -1377,6 +1389,10 @@
157 }
158 #endif /* UNIV_DEBUG */
159 buf_flush_write_block_low(bpage);
160+
161+ if (flush_type == BUF_FLUSH_LIST) {
162+ mutex_enter(&buf_pool->zip_dirty_flush_mutex);
163+ }
164 }
165
166 /***********************************************************//**
167@@ -1402,7 +1418,9 @@
168 buf_pool_t* buf_pool = buf_pool_get(space, offset);
169 ibool is_forward_scan;
170
171- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
172+ ut_ad(flush_type == BUF_FLUSH_LRU
173+ || (flush_type == BUF_FLUSH_LIST
174+ && mutex_own(&buf_pool->zip_dirty_flush_mutex)));
175
176 if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN || !srv_flush_neighbor_pages) {
177 /* If there is little space, it is better not to flush
178@@ -1577,8 +1595,10 @@
179 #endif /* UNIV_DEBUG */
180
181 //ut_ad(buf_pool_mutex_own(buf_pool));
182- ut_ad(flush_type != BUF_FLUSH_LRU
183- || mutex_own(&buf_pool->LRU_list_mutex));
184+ ut_ad((flush_type == BUF_FLUSH_LRU
185+ && mutex_own(&buf_pool->LRU_list_mutex))
186+ || (flush_type == BUF_FLUSH_LIST
187+ && mutex_own(&buf_pool->zip_dirty_flush_mutex)));
188
189 block_mutex = buf_page_get_mutex_enter(bpage);
190
191@@ -1620,8 +1640,10 @@
192 }
193
194 //ut_ad(buf_pool_mutex_own(buf_pool));
195- ut_ad(flush_type != BUF_FLUSH_LRU
196- || mutex_own(&buf_pool->LRU_list_mutex));
197+ ut_ad((flush_type == BUF_FLUSH_LRU
198+ && mutex_own(&buf_pool->LRU_list_mutex))
199+ || (flush_type == BUF_FLUSH_LIST
200+ && mutex_own(&buf_pool->zip_dirty_flush_mutex)));
201
202 return(flushed);
203 }
204@@ -1701,6 +1723,7 @@
205
206 /* If we have flushed enough, leave the loop */
207 do {
208+ mutex_enter(&buf_pool->zip_dirty_flush_mutex);
209 /* Start from the end of the list looking for a suitable
210 block to be flushed. */
211
212@@ -1723,6 +1746,7 @@
213
214 /* We have flushed enough */
215 buf_flush_list_mutex_exit(buf_pool);
216+ mutex_exit(&buf_pool->zip_dirty_flush_mutex);
217 break;
218 }
219
220@@ -1732,6 +1756,9 @@
221
222 buf_flush_list_mutex_exit(buf_pool);
223
224+ /* After the flush list mutex is released, the block is
225+ protected from relocation by the zip_dirty_flush_mutex. */
226+
227 /* The list may change during the flushing and we cannot
228 safely preserve within this function a pointer to a
229 block in the list! */
230@@ -1774,6 +1801,7 @@
231
232 --len;
233 }
234+ mutex_exit(&buf_pool->zip_dirty_flush_mutex);
235
236 } while (count < min_n && bpage != NULL && len > 0);
237
238
239=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
240--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-01-18 03:34:53 +0000
241+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-01-23 10:49:28 +0000
242@@ -282,6 +282,8 @@
243 {&buf_pool_zip_mutex_key, "buf_pool_zip_mutex", 0},
244 {&buf_pool_LRU_list_mutex_key, "buf_pool_LRU_list_mutex", 0},
245 {&buf_pool_free_list_mutex_key, "buf_pool_free_list_mutex", 0},
246+ {&buf_pool_zip_dirty_flush_mutex_key, "buf_pool_zip_dirty_flush_mutex",
247+ 0},
248 {&buf_pool_zip_free_mutex_key, "buf_pool_zip_free_mutex", 0},
249 {&buf_pool_zip_hash_mutex_key, "buf_pool_zip_hash_mutex", 0},
250 {&cache_last_read_mutex_key, "cache_last_read_mutex", 0},
251
252=== modified file 'Percona-Server/storage/innobase/include/buf0buf.h'
253--- Percona-Server/storage/innobase/include/buf0buf.h 2013-01-17 22:50:22 +0000
254+++ Percona-Server/storage/innobase/include/buf0buf.h 2013-01-23 10:49:28 +0000
255@@ -1769,6 +1769,10 @@
256 mutex_t LRU_list_mutex;
257 rw_lock_t page_hash_latch;
258 mutex_t free_list_mutex;
259+ mutex_t zip_dirty_flush_mutex; /*!< Mutex protecting the
260+ compressed page relocation and flush
261+ list page accesses after the flush list
262+ mutex release */
263 mutex_t zip_free_mutex;
264 mutex_t zip_hash_mutex;
265 ulint instance_no; /*!< Array index of this buffer
266
267=== modified file 'Percona-Server/storage/innobase/include/sync0sync.h'
268--- Percona-Server/storage/innobase/include/sync0sync.h 2012-05-10 07:49:14 +0000
269+++ Percona-Server/storage/innobase/include/sync0sync.h 2013-01-23 10:49:28 +0000
270@@ -75,6 +75,7 @@
271 extern mysql_pfs_key_t buffer_block_mutex_key;
272 extern mysql_pfs_key_t buf_pool_mutex_key;
273 extern mysql_pfs_key_t buf_pool_zip_mutex_key;
274+extern mysql_pfs_key_t buf_pool_zip_dirty_flush_mutex_key;
275 extern mysql_pfs_key_t buf_pool_LRU_list_mutex_key;
276 extern mysql_pfs_key_t buf_pool_free_list_mutex_key;
277 extern mysql_pfs_key_t buf_pool_zip_free_mutex_key;
278@@ -682,6 +683,7 @@
279 SYNC_SEARCH_SYS, as memory allocation
280 can call routines there! Otherwise
281 the level is SYNC_MEM_HASH. */
282+#define SYNC_BUF_ZIP_DIRTY_FLUSH 159
283 #define SYNC_BUF_LRU_LIST 158
284 #define SYNC_BUF_PAGE_HASH 157
285 #define SYNC_BUF_BLOCK 155 /* Block mutex */
286
287=== modified file 'Percona-Server/storage/innobase/sync/sync0sync.c'
288--- Percona-Server/storage/innobase/sync/sync0sync.c 2012-05-10 07:49:14 +0000
289+++ Percona-Server/storage/innobase/sync/sync0sync.c 2013-01-23 10:49:28 +0000
290@@ -1248,6 +1248,7 @@
291 }
292 break;
293 case SYNC_SEARCH_SYS:
294+ case SYNC_BUF_ZIP_DIRTY_FLUSH:
295 case SYNC_BUF_LRU_LIST:
296 case SYNC_BUF_FLUSH_LIST:
297 case SYNC_BUF_PAGE_HASH:

Subscribers

People subscribed via source and target branches