Merge lp:~akopytov/percona-server/bug1070856-5.5 into lp:percona-server/5.5

Proposed by Alexey Kopytov
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 368
Proposed branch: lp:~akopytov/percona-server/bug1070856-5.5
Merge into: lp:percona-server/5.5
Diff against target: 53 lines (+24/-0)
3 files modified
Percona-Server/include/my_sys.h (+1/-0)
Percona-Server/mysys/mf_cache.c (+18/-0)
Percona-Server/sql/log.cc (+5/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug1070856-5.5
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
George Ormond Lorch III (community) g2 Approve
Vlad Lesin (community) Approve
Review via email: mp+131515@code.launchpad.net

Description of the change

    Bug #1070856: Temporary files created by binary log cache are not purged
                  after transaction commit

    The problem was that the temporary file used to cache transactions for
    the binary log was initialized once (when the in-memory buffer was
    exceeded) and close (and thus, removed) only when closing the
    connection. Which might lead to problems with large temporary files
    being created and not removed in case of persistent connections and
    large transactions (i.e. LOAD DATA INFILE).

    Fixed by truncating the temporary file, if used for a binary log
    transaction cache, when committing or rolling back a statement or a
    transaction.

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Alexey Kopytov (akopytov) wrote :

ST 26926

Revision history for this message
Vlad Lesin (vlad-lesin) wrote :

Looks good. See my comment for 5.1.

Revision history for this message
Vlad Lesin (vlad-lesin) wrote :

I agree the code for testing such small fix would be redundant.

review: Approve
Revision history for this message
George Ormond Lorch III (gl-az) :
review: Approve (g2)
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
1=== modified file 'Percona-Server/include/my_sys.h'
2--- Percona-Server/include/my_sys.h 2012-05-10 07:49:14 +0000
3+++ Percona-Server/include/my_sys.h 2012-10-26 05:11:24 +0000
4@@ -752,6 +752,7 @@
5 const char *prefix, size_t cache_size,
6 myf cache_myflags);
7 extern my_bool real_open_cached_file(IO_CACHE *cache);
8+extern my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos);
9 extern void close_cached_file(IO_CACHE *cache);
10 File create_temp_file(char *to, const char *dir, const char *pfx,
11 int mode, myf MyFlags);
12
13=== modified file 'Percona-Server/mysys/mf_cache.c'
14--- Percona-Server/mysys/mf_cache.c 2011-06-30 15:46:53 +0000
15+++ Percona-Server/mysys/mf_cache.c 2012-10-26 05:11:24 +0000
16@@ -119,3 +119,21 @@
17 }
18 DBUG_VOID_RETURN;
19 }
20+
21+/*
22+ Truncate the cached file to a given offset. The cache must be reinitialized
23+ with reinit_io_cache() after this call.
24+*/
25+
26+my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos)
27+{
28+ DBUG_ENTER("truncate_cached_file");
29+
30+ if (my_b_inited(cache) && cache->file > -1)
31+ {
32+ if (my_chsize(cache->file, pos, 0, MYF(MY_WME)))
33+ DBUG_RETURN(TRUE);
34+ }
35+
36+ DBUG_RETURN(FALSE);
37+}
38
39=== modified file 'Percona-Server/sql/log.cc'
40--- Percona-Server/sql/log.cc 2012-10-17 03:47:45 +0000
41+++ Percona-Server/sql/log.cc 2012-10-26 05:11:24 +0000
42@@ -395,6 +395,11 @@
43 delete pending();
44 set_pending(0);
45 }
46+ /*
47+ Truncate the temporary file to reclaim disk space occupied by cached
48+ transactions on COMMIT/ROLLBACK.
49+ */
50+ truncate_cached_file(&cache_log, pos);
51 reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, 0);
52 cache_log.end_of_file= saved_max_binlog_cache_size;
53 }

Subscribers

People subscribed via source and target branches