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

Proposed by Laurynas Biveinis on 2014-06-11
Status: Merged
Approved by: Sergei Glushchenko on 2014-07-14
Approved revision: 662
Merged at revision: 679
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1193332-5.5
Merge into: lp:percona-server/5.5
Diff against target: 221 lines (+120/-19)
7 files modified
mysql-test/suite/innodb/r/percona_changed_page_bmp_debug.result (+16/-0)
mysql-test/suite/innodb/t/percona_changed_page_bmp_debug.test (+56/-0)
storage/innobase/handler/i_s.cc (+12/-0)
storage/innobase/include/log0log.h (+12/-0)
storage/innobase/include/log0log.ic (+21/-0)
storage/innobase/log/log0log.c (+0/-19)
storage/innobase/log/log0online.c (+3/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1193332-5.5
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 2014-06-11 Approve on 2014-07-14
Review via email: mp+222799@code.launchpad.net

Description of the change

Fix bug 1193332 ([Warning] InnoDB: changed page bitmap file
'./ib_modified_log_11_951286349.xdb' does not contain a complete run
at the end.)

The problem is bitmap writer thread working in parallel with bitmap
reader that processes an INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
query, causing the latter to see partial data in the middle of the
write. The fix is, if the log tracker is running, to limit any
maximum LSN value for a query with an actual tracked LSN value.

Add a testcase to percona_changed_page_bmp_debug.

    http://jenkins.percona.com/job/percona-server-5.5-param/1009/

To post a comment you must log in.

Approve

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mysql-test/suite/innodb/r/percona_changed_page_bmp_debug.result'
--- mysql-test/suite/innodb/r/percona_changed_page_bmp_debug.result 2013-09-25 05:52:09 +0000
+++ mysql-test/suite/innodb/r/percona_changed_page_bmp_debug.result 2014-06-11 13:20:55 +0000
@@ -42,3 +42,19 @@
42ERROR HY000: Can't read record in system table42ERROR HY000: Can't read record in system table
43SET DEBUG_SYNC="RESET";43SET DEBUG_SYNC="RESET";
44DROP TABLE t2;44DROP TABLE t2;
45RESET CHANGED_PAGE_BITMAPS;
464th restart
47SET DEBUG_SYNC="i_s_innodb_changed_pages_range_ready SIGNAL ready WAIT_FOR finish";
48SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES;
49SET DEBUG_SYNC="now WAIT_FOR ready";
50SET @@GLOBAL.innodb_track_changed_pages=FALSE;
51SET @@GLOBAL.innodb_log_checkpoint_now=TRUE;
52CREATE TABLE t1 (a INT)ENGINE=InnoDB;
53INSERT INTO t1 VALUES (1);
54CREATE TABLE t2 (a INT) ENGINE=InnoDB;
55INSERT INTO t2 VALUES (2);
56SET @@GLOBAL.innodb_log_checkpoint_now=TRUE;
57SET @@GLOBAL.innodb_track_changed_pages=TRUE;
58SET @@GLOBAL.innodb_track_redo_log_now=TRUE;
59SET DEBUG_SYNC="now SIGNAL finish";
60DROP TABLE t1, t2;
4561
=== modified file 'mysql-test/suite/innodb/t/percona_changed_page_bmp_debug.test'
--- mysql-test/suite/innodb/t/percona_changed_page_bmp_debug.test 2013-09-25 05:52:09 +0000
+++ mysql-test/suite/innodb/t/percona_changed_page_bmp_debug.test 2014-06-11 13:20:55 +0000
@@ -130,5 +130,61 @@
130disconnect con2;130disconnect con2;
131131
132DROP TABLE t2;132DROP TABLE t2;
133RESET CHANGED_PAGE_BITMAPS;
134
135--source include/wait_until_count_sessions.inc
136
137#
138# Test for bug 1193332 ([Warning] InnoDB: changed page bitmap file
139# './ib_modified_log_11_951286349.xdb' does not contain a complete run at the end.)
140#
141
142# Setup an error on the 2nd bitmap page write, so that bitmap contains an incomplete run
143--echo 4th restart
144--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
145--shutdown_server 10
146--source include/wait_until_disconnected.inc
147--enable_reconnect
148--exec echo "restart:-#d,bitmap_page_2_write_error" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
149--source include/wait_until_connected_again.inc
150
151--source include/count_sessions.inc
152
153--connect(con2,localhost,root,,)
154
155SET DEBUG_SYNC="i_s_innodb_changed_pages_range_ready SIGNAL ready WAIT_FOR finish";
156send SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES;
157
158--connection default
159
160SET DEBUG_SYNC="now WAIT_FOR ready";
161
162# Pause the log tracker
163SET @@GLOBAL.innodb_track_changed_pages=FALSE;
164SET @@GLOBAL.innodb_log_checkpoint_now=TRUE;
165
166# Prepare two pages of bitmap data
167CREATE TABLE t1 (a INT)ENGINE=InnoDB;
168INSERT INTO t1 VALUES (1);
169CREATE TABLE t2 (a INT) ENGINE=InnoDB;
170INSERT INTO t2 VALUES (2);
171
172# Resume the log tracker so it crashes after writing one page
173SET @@GLOBAL.innodb_log_checkpoint_now=TRUE;
174SET @@GLOBAL.innodb_track_changed_pages=TRUE;
175SET @@GLOBAL.innodb_track_redo_log_now=TRUE;
176
177SET DEBUG_SYNC="now SIGNAL finish";
178
179--connection con2
180# With the bug present the query will fail with ER_CANT_FIND_SYSTEM_REC
181--disable_result_log
182reap;
183--enable_result_log
184
185--disconnect con2
186--connection default
187
188DROP TABLE t1, t2;
133189
134--source include/wait_until_count_sessions.inc190--source include/wait_until_count_sessions.inc
135191
=== modified file 'storage/innobase/handler/i_s.cc'
--- storage/innobase/handler/i_s.cc 2013-10-31 11:50:31 +0000
+++ storage/innobase/handler/i_s.cc 2014-06-11 13:20:55 +0000
@@ -42,6 +42,7 @@
42#include "i_s.h"42#include "i_s.h"
43#include <sql_plugin.h>43#include <sql_plugin.h>
44#include <mysql/innodb_priv.h>44#include <mysql/innodb_priv.h>
45#include <debug_sync.h>
4546
46extern "C" {47extern "C" {
47#include "btr0pcur.h" /* for file sys_tables related info. */48#include "btr0pcur.h" /* for file sys_tables related info. */
@@ -7511,12 +7512,23 @@
7511 limit_lsn_range_from_condition(table, cond, &min_lsn,7512 limit_lsn_range_from_condition(table, cond, &min_lsn,
7512 &max_lsn);7513 &max_lsn);
7513 }7514 }
7515
7516 /* If the log tracker is running and our max_lsn > current tracked LSN,
7517 cap the max lsn so that we don't try to read any partial runs as the
7518 tracked LSN advances. */
7519 if (srv_track_changed_pages) {
7520 ib_uint64_t tracked_lsn = log_get_tracked_lsn();
7521 if (max_lsn > tracked_lsn)
7522 max_lsn = tracked_lsn;
7523 }
75147524
7515 if (!log_online_bitmap_iterator_init(&i, min_lsn, max_lsn)) {7525 if (!log_online_bitmap_iterator_init(&i, min_lsn, max_lsn)) {
7516 my_error(ER_CANT_FIND_SYSTEM_REC, MYF(0));7526 my_error(ER_CANT_FIND_SYSTEM_REC, MYF(0));
7517 DBUG_RETURN(1);7527 DBUG_RETURN(1);
7518 }7528 }
75197529
7530 DEBUG_SYNC(thd, "i_s_innodb_changed_pages_range_ready");
7531
7520 while(log_online_bitmap_iterator_next(&i) &&7532 while(log_online_bitmap_iterator_next(&i) &&
7521 (!srv_max_changed_pages ||7533 (!srv_max_changed_pages ||
7522 output_rows_num < srv_max_changed_pages) &&7534 output_rows_num < srv_max_changed_pages) &&
75237535
=== modified file 'storage/innobase/include/log0log.h'
--- storage/innobase/include/log0log.h 2013-12-05 08:07:26 +0000
+++ storage/innobase/include/log0log.h 2014-06-11 13:20:55 +0000
@@ -581,6 +581,18 @@
581log_mem_free(void);581log_mem_free(void);
582/*==============*/582/*==============*/
583583
584/****************************************************************//**
585Safely reads the log_sys->tracked_lsn value. Uses atomic operations
586if available, otherwise this field is protected with the log system
587mutex. The writer counterpart function is log_set_tracked_lsn() in
588log0online.c.
589
590@return log_sys->tracked_lsn value. */
591UNIV_INLINE
592ib_uint64_t
593log_get_tracked_lsn(void);
594/*=====================*/
595
584extern log_t* log_sys;596extern log_t* log_sys;
585597
586/* Values used as flags */598/* Values used as flags */
587599
=== modified file 'storage/innobase/include/log0log.ic'
--- storage/innobase/include/log0log.ic 2013-08-02 09:40:55 +0000
+++ storage/innobase/include/log0log.ic 2014-06-11 13:20:55 +0000
@@ -459,3 +459,24 @@
459 }459 }
460}460}
461#endif /* !UNIV_HOTBACKUP */461#endif /* !UNIV_HOTBACKUP */
462
463/****************************************************************//**
464Safely reads the log_sys->tracked_lsn value. Uses atomic operations
465if available, otherwise this field is protected with the log system
466mutex. The writer counterpart function is log_set_tracked_lsn() in
467log0online.c.
468
469@return log_sys->tracked_lsn value. */
470UNIV_INLINE
471ib_uint64_t
472log_get_tracked_lsn(void)
473/*=====================*/
474{
475#ifdef HAVE_ATOMIC_BUILTINS_64
476 return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0);
477#else
478 ut_ad(mutex_own(&(log_sys->mutex)));
479 return log_sys->tracked_lsn;
480#endif
481}
482
462483
=== modified file 'storage/innobase/log/log0log.c'
--- storage/innobase/log/log0log.c 2013-12-05 08:07:26 +0000
+++ storage/innobase/log/log0log.c 2014-06-11 13:20:55 +0000
@@ -215,25 +215,6 @@
215}215}
216216
217/****************************************************************//**217/****************************************************************//**
218Safely reads the log_sys->tracked_lsn value. Uses atomic operations
219if available, otherwise this field is protected with the log system
220mutex. The writer counterpart function is log_set_tracked_lsn() in
221log0online.c.
222
223@return log_sys->tracked_lsn value. */
224UNIV_INLINE
225ib_uint64_t
226log_get_tracked_lsn()
227{
228#ifdef HAVE_ATOMIC_BUILTINS_64
229 return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0);
230#else
231 ut_ad(mutex_own(&(log_sys->mutex)));
232 return log_sys->tracked_lsn;
233#endif
234}
235
236/****************************************************************//**
237Checks if the log groups have a big enough margin of free space in218Checks if the log groups have a big enough margin of free space in
238so that a new log entry can be written without overwriting log data219so that a new log entry can be written without overwriting log data
239that is not read by the changed page bitmap thread.220that is not read by the changed page bitmap thread.
240221
=== modified file 'storage/innobase/log/log0online.c'
--- storage/innobase/log/log0online.c 2014-02-14 07:44:36 +0000
+++ storage/innobase/log/log0online.c 2014-06-11 13:20:55 +0000
@@ -1202,6 +1202,9 @@
12021202
1203 bmp_tree_node = (ib_rbt_node_t*)1203 bmp_tree_node = (ib_rbt_node_t*)
1204 rbt_next(log_bmp_sys->modified_pages, bmp_tree_node);1204 rbt_next(log_bmp_sys->modified_pages, bmp_tree_node);
1205
1206 DBUG_EXECUTE_IF("bitmap_page_2_write_error",
1207 DBUG_SET("+d,bitmap_page_write_error"););
1205 }1208 }
12061209
1207 rbt_reset(log_bmp_sys->modified_pages);1210 rbt_reset(log_bmp_sys->modified_pages);

Subscribers

People subscribed via source and target branches