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
=== modified file 'Percona-Server/include/my_sys.h'
--- Percona-Server/include/my_sys.h 2012-05-10 07:49:14 +0000
+++ Percona-Server/include/my_sys.h 2012-10-26 05:11:24 +0000
@@ -752,6 +752,7 @@
752 const char *prefix, size_t cache_size,752 const char *prefix, size_t cache_size,
753 myf cache_myflags);753 myf cache_myflags);
754extern my_bool real_open_cached_file(IO_CACHE *cache);754extern my_bool real_open_cached_file(IO_CACHE *cache);
755extern my_bool truncate_cached_file(IO_CACHE *cache, my_off_t pos);
755extern void close_cached_file(IO_CACHE *cache);756extern void close_cached_file(IO_CACHE *cache);
756File create_temp_file(char *to, const char *dir, const char *pfx,757File create_temp_file(char *to, const char *dir, const char *pfx,
757 int mode, myf MyFlags);758 int mode, myf MyFlags);
758759
=== modified file 'Percona-Server/mysys/mf_cache.c'
--- Percona-Server/mysys/mf_cache.c 2011-06-30 15:46:53 +0000
+++ Percona-Server/mysys/mf_cache.c 2012-10-26 05:11:24 +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-10-17 03:47:45 +0000
+++ Percona-Server/sql/log.cc 2012-10-26 05:11:24 +0000
@@ -395,6 +395,11 @@
395 delete pending();395 delete pending();
396 set_pending(0);396 set_pending(0);
397 }397 }
398 /*
399 Truncate the temporary file to reclaim disk space occupied by cached
400 transactions on COMMIT/ROLLBACK.
401 */
402 truncate_cached_file(&cache_log, pos);
398 reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, 0);403 reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, 0);
399 cache_log.end_of_file= saved_max_binlog_cache_size;404 cache_log.end_of_file= saved_max_binlog_cache_size;
400 }405 }

Subscribers

People subscribed via source and target branches