Merge lp:~akopytov/percona-server/bug1162085-5.1 into lp:percona-server/5.1

Proposed by Alexey Kopytov
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 547
Proposed branch: lp:~akopytov/percona-server/bug1162085-5.1
Merge into: lp:percona-server/5.1
Diff against target: 70 lines (+41/-3)
3 files modified
Percona-Server/mysql-test/suite/binlog/r/percona_bug1162085.result (+6/-0)
Percona-Server/mysql-test/suite/binlog/t/percona_bug1162085.test (+30/-0)
Percona-Server/mysys/mf_cache.c (+5/-3)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug1162085-5.1
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+156355@code.launchpad.net

Description of the change

    Bug #1162085: Percona server 5.5.30-rel30.1.465 reproducable hang

    The fix for bug #1070856 that the underlying binlog cache file is always
    larger then the offset passed to truncate_cached_file(). Which is not
    always the case, because a part of the data which has already been
    written may be in the IO_CACHE buffer, but not yet on disk.

    What happened in the test case was that the server wrote ~48K data into
    the binlog cache with 32K written to disk and the remaining part
    residing in the IO_CACHE buffer. On the ROLLBACK TO statement the server
    called truncate_cached_file() with the 48K offset, in which case
    my_chsize() actually increased the underlying file by appending 16K worth
    of zero bytes. When the remaining 16K bytes were eventually flushed to
    disk on COMMIT, my_b_flush_io_cache() appended them again to the file,
    resulting in the 64K total file size. This in turn led to
    MYSQL_BIN_LOG::write_cache() hanging when reading bogus zero bytes due
    to nonsensical zero offsets in the binlog cache.

    Fixed truncate_cached_file() to only call my_chsize() when the
    underlying cache file is larger than the passed offset.

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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'Percona-Server/mysql-test/suite/binlog/r/percona_bug1162085.result'
--- Percona-Server/mysql-test/suite/binlog/r/percona_bug1162085.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/binlog/r/percona_bug1162085.result 2013-04-01 14:18:23 +0000
@@ -0,0 +1,6 @@
1CREATE TABLE t1 (data LONGBLOB) ENGINE=InnoDB;
2START TRANSACTION;
3SAVEPOINT savepoint_1;
4ROLLBACK TO SAVEPOINT_1;
5COMMIT;
6DROP TABLE t1;
07
=== added file 'Percona-Server/mysql-test/suite/binlog/t/percona_bug1162085.test'
--- Percona-Server/mysql-test/suite/binlog/t/percona_bug1162085.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/binlog/t/percona_bug1162085.test 2013-04-01 14:18:23 +0000
@@ -0,0 +1,30 @@
1########################################################################
2# Bug #1162085: Percona server 5.5.30-rel30.1.465 reproducable hang
3########################################################################
4
5-- source include/have_log_bin.inc
6-- source include/have_innodb.inc
7
8CREATE TABLE t1 (data LONGBLOB) ENGINE=InnoDB;
9
10START TRANSACTION;
11
12--disable_query_log
13let $i=1024;
14while($i)
15{
16 # Don't use REPEAT() here so we generate long enough writes to the
17 # binlog cache in both stmt and row-based mode
18
19 INSERT INTO t1 (data) VALUES ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
20 dec $i;
21}
22--enable_query_log
23
24SAVEPOINT savepoint_1;
25
26ROLLBACK TO SAVEPOINT_1;
27
28COMMIT;
29
30DROP TABLE t1;
031
=== modified file 'Percona-Server/mysys/mf_cache.c'
--- Percona-Server/mysys/mf_cache.c 2012-10-25 17:55:07 +0000
+++ Percona-Server/mysys/mf_cache.c 2013-04-01 14:18:23 +0000
@@ -121,15 +121,17 @@
121}121}
122122
123/*123/*
124 Truncate the cached file to a given offset. The cache must be reinitialized124 Truncate the cached file to a given offset, if the current size is greater
125 with reinit_io_cache() after this call.125 than the offset. The cache must be reinitialized with reinit_io_cache() after
126 this call.
126*/127*/
127128
128my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos)129my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos)
129{130{
130 DBUG_ENTER("truncate_cached_file");131 DBUG_ENTER("truncate_cached_file");
131132
132 if (my_b_inited(cache) && cache->file > -1)133 if (my_b_inited(cache) && cache->file > -1 &&
134 my_seek(cache->file, 0L, MY_SEEK_END, MYF(MY_WME + MY_FAE)) > pos)
133 {135 {
134 if (my_chsize(cache->file, pos, 0, MYF(MY_WME)))136 if (my_chsize(cache->file, pos, 0, MYF(MY_WME)))
135 DBUG_RETURN(TRUE);137 DBUG_RETURN(TRUE);

Subscribers

People subscribed via source and target branches