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: no longer in the source branch.
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 (community) 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
=== modified file 'Percona-Server/include/my_sys.h'
--- Percona-Server/include/my_sys.h 2011-11-24 02:01:56 +0000
+++ Percona-Server/include/my_sys.h 2012-10-26 05:10:26 +0000
@@ -801,6 +801,7 @@
801 const char *prefix, size_t cache_size,801 const char *prefix, size_t cache_size,
802 myf cache_myflags);802 myf cache_myflags);
803extern my_bool real_open_cached_file(IO_CACHE *cache);803extern my_bool real_open_cached_file(IO_CACHE *cache);
804extern my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos);
804extern void close_cached_file(IO_CACHE *cache);805extern void close_cached_file(IO_CACHE *cache);
805File create_temp_file(char *to, const char *dir, const char *pfx,806File create_temp_file(char *to, const char *dir, const char *pfx,
806 int mode, myf MyFlags);807 int mode, myf MyFlags);
807808
=== modified file 'Percona-Server/mysys/mf_cache.c'
--- Percona-Server/mysys/mf_cache.c 2007-05-10 09:59:39 +0000
+++ Percona-Server/mysys/mf_cache.c 2012-10-26 05:10:26 +0000
@@ -119,3 +119,21 @@
119 }119 }
120 DBUG_VOID_RETURN;120 DBUG_VOID_RETURN;
121}121}
122
123/*
124 Truncate the cached file to a given offset. The cache must be reinitialized
125 with reinit_io_cache() after this call.
126*/
127
128my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos)
129{
130 DBUG_ENTER("truncate_cached_file");
131
132 if (my_b_inited(cache) && cache->file > -1)
133 {
134 if (my_chsize(cache->file, pos, 0, MYF(MY_WME)))
135 DBUG_RETURN(TRUE);
136 }
137
138 DBUG_RETURN(FALSE);
139}
122140
=== modified file 'Percona-Server/sql/log.cc'
--- Percona-Server/sql/log.cc 2012-08-20 03:14:02 +0000
+++ Percona-Server/sql/log.cc 2012-10-26 05:10:26 +0000
@@ -187,7 +187,14 @@
187 delete pending();187 delete pending();
188 }188 }
189 set_pending(0);189 set_pending(0);
190
191 /*
192 Truncate the temporary file to reclaim disk space occupied by cached
193 transactions on COMMIT/ROLLBACK.
194 */
195 truncate_cached_file(&trans_log, pos);
190 reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0);196 reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0);
197
191 trans_log.end_of_file= max_binlog_cache_size;198 trans_log.end_of_file= max_binlog_cache_size;
192 if (pos < before_stmt_pos)199 if (pos < before_stmt_pos)
193 before_stmt_pos= MY_OFF_T_UNDEF;200 before_stmt_pos= MY_OFF_T_UNDEF;

Subscribers

People subscribed via source and target branches