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

Proposed by Alexey Kopytov
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: 495
Merged at revision: 502
Proposed branch: lp:~akopytov/percona-server/bug1070856-5.1
Merge into: lp:percona-server/5.1
Diff against target: 56 lines (+26/-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 (+7/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug1070856-5.1
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
George Ormond Lorch III g2 Approve
Vlad Lesin (community) Approve
Review via email: mp+131514@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.

It would be great if there would be possibility to test it. Maybe it would me reasonable to add I_S that would show the size of current session cache size?

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

Vlad,

I agree that having an I_S table or a status variable would make creating an automated test possible. But the amount of code and time required to implement, test and document that table/variable look unreasonably high for such a small fix.

Btw, why did you just added a comment without adding yourself as a reviewer?

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

I agree.

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 2011-11-24 02:01:56 +0000
3+++ Percona-Server/include/my_sys.h 2012-10-26 05:10:26 +0000
4@@ -801,6 +801,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 2007-05-10 09:59:39 +0000
15+++ Percona-Server/mysys/mf_cache.c 2012-10-26 05:10:26 +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-08-20 03:14:02 +0000
41+++ Percona-Server/sql/log.cc 2012-10-26 05:10:26 +0000
42@@ -187,7 +187,14 @@
43 delete pending();
44 }
45 set_pending(0);
46+
47+ /*
48+ Truncate the temporary file to reclaim disk space occupied by cached
49+ transactions on COMMIT/ROLLBACK.
50+ */
51+ truncate_cached_file(&trans_log, pos);
52 reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0);
53+
54 trans_log.end_of_file= max_binlog_cache_size;
55 if (pos < before_stmt_pos)
56 before_stmt_pos= MY_OFF_T_UNDEF;

Subscribers

People subscribed via source and target branches